Weird behavior of kwargs["parm"] in a callbackscript.

   2505   1   0
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
It seems there's some conflict going on.

I'm using a callback script for myFirstParameter that calls myFunction(parm) in the Python Module.
the callback script goes like:
hou.phm().myFunction(kwargs["parm"])
The problem seems to arise when you create a new parameter and forget to register its name, Houdini by default would call it “parm”.
When you later update the new parameter with a custom name “mySecondParameter”, Houdini seems to automatically update the callback script function in the very first parameter. Now the callback is:
 hou.phm().myFunction(kwargs["mySecondParameter"])

And when you use myFirstParameter you would get the error: Error running callback: Traceback (most recent call last):
File “<stdin>”, line 1, in <module> KeyError: ('mySecondParameter',)



Does it look like a bug or is that the natural behavior of how things should go?
Can you reproduce it?
Edited by Andr - Feb. 8, 2019 14:10:44
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
It's logged as bug #94685

It's a problem easy to fix when you know how it happens otherwise you could be puzzled a bit.
A good practice is to never leave a new parm registered with the default “parm” name, especially if you are using callback scripts with kwargs.
I know it can happen especially when you are testing a lot of parameters, so be aware that if you get a KeyError and you know you have a callbackscript with kwargs, review the callback and sees if it has changed.

if you want to see this behavior in action have a look at the file, and see if you can reproduce it (just by changing the name of the default parm)
Edited by Andr - Feb. 11, 2019 04:39:40

Attachments:
Andr_kwargs_conflict.hdalc (3.4 KB)

  • Quick Links