Error when applying expression in Python

17 views
Skip to first unread message

Carlo Giesa

unread,
Sep 10, 2025, 6:53:26 AMSep 10
to gaffer-dev
Hi there!

Not sure if that is a bug or if I'm doing something wrong. I attached a basic Gaffer scene file and a little Python snippet. When I execute the Python snippet, I get following error (formatting is broken):

IECore.Exception : line 71 : Traceback (most recent call last): File "/uvfx/Projects/umediavfx/software/opensource/gaffer/1.5.15.0-gcc11/python/Gaffer/PythonExpressionEngine.py", line 63, in parse inPlugs.extend( [ self.__plug( node, p ) for p in self.__inPlugPaths ] ) File "/uvfx/Projects/umediavfx/software/opensource/gaffer/1.5.15.0-gcc11/python/Gaffer/PythonExpressionEngine.py", line 63, in inPlugs.extend( [ self.__plug( node, p ) for p in self.__inPlugPaths ] ) File "/uvfx/Projects/umediavfx/software/opensource/gaffer/1.5.15.0-gcc11/python/Gaffer/PythonExpressionEngine.py", line 212, in __plug plug = plug[p] TypeError: 'NoneType' object is not subscriptable

But, if I create the expression manually and I copy/paste the same expression in it, it works as expected.

Any hint?

Greets,
Carlo

PS: I tried to "clean up" the gaffer file as much as possible to avoid any internal tools. The publisher node looks quite messy in a vanilla gaffer, but the error can be reproduced (and creating the expression manually does work as expected as well).
expression_error.py
expression_error.gfr

Carlo Giesa

unread,
Sep 10, 2025, 6:54:01 AMSep 10
to gaffer-dev
Tested as well in Gaffer 1.5.16.1 with the same result.

John Haddon

unread,
Sep 10, 2025, 9:48:39 AMSep 10
to gaffe...@googlegroups.com
Hi Carlo,

I don't know if I'm missing something in how I'm meant to run this, but just running your `.py` file in the PythonEditor does give the same error. The issue is that you must parent the Expression node to the script before calling `setExpression()`, because otherwise the node can't find the plugs it is meant to connect to. If I add `root.addChild( expr_node )` just before `setExpression()` then all seems to work OK.

Could it be that simple, or am I missing something else?

Cheers...
John

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/gaffer-dev/f2db94d3-232a-40c8-9461-a057bca3aefcn%40googlegroups.com.

Carlo Giesa

unread,
Sep 10, 2025, 10:24:28 AMSep 10
to gaffe...@googlegroups.com
Oh my dear..... I guess it's that simple. 🫣
Sorry for the noise.... I feel ashamed. 😶‍🌫️
But thanks anyway!

John Haddon

unread,
Sep 10, 2025, 12:52:08 PMSep 10
to gaffe...@googlegroups.com
To be fair, `'NoneType' object is not subscriptable` isn't exactly a helpful error message...
Glad we've got it working...
Cheers...
John

Reply all
Reply to author
Forward
0 new messages