Problem summary
When loading a macro of a custom user type that is set to the exact string of a registered node type, for example the macro’s exact name, a recursive loop is created which leads to a RuntimeError: maximum recursion depth exceeded.
Steps to reproduce
1. Launch Katana and run the following script in the Python tab:
import os
from Katana import KatanaFile
from Katana import NodegraphAPI
from Katana import UserNodes
print "WARNING: I'm going to overwrite ~/.katana/Macro/_User/WibbleWobble.macro"
# Set up a group node and change it's type
groupNode = NodegraphAPI.CreateNode('Group',NodegraphAPI.GetRootNode())
groupNode.setType('WibbleWobble_User')
# Form the output filepath
homeDir = os.environ.get('HOME','/tmp’')
pluginDir = os.path.join(homeDir,'.katana','Macros','_User')
macroPath = os.path.join(pluginDir,'WibbleWobble.macro')
# Export the macro
#KatanaFile.Export(macroPath,[groupNode])
UserNodes.PublishNode(groupNode,macroPath)
# Clean out the scene
KatanaFile.New()
# Create the newly created Group_User macro
try:
testNode = NodegraphAPI.CreateNode('WibbleWobble_User',NodegraphAPI.GetRootNode())
except Exception as e:
print "Caught this exception: %s" % e
testNode = None
print "Child nodes: %s" % testNode.getChildren()
print "All nodes: %s" % NodegraphAPI.GetAllNodes()
2. Executing the script will lock the UI for an extended period of time and print these errors:
Error in sys.excepthook:
Traceback (most recent call last):
File "python/UI4/Util/LogRecordHandler.py", line 96, in excepthook
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/logging/__init__.py", line 1455, in exception
error(*((msg,)+args), **{'exc_info': 1})
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/logging/__init__.py", line 1448, in error
root.error(*((msg,)+args), **kwargs)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/logging/__init__.py", line 1074, in error
self._log(ERROR, msg, args, **kwargs)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/logging/__init__.py", line 1164, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/logging/__init__.py", line 1139, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/logging/__init__.py", line 252, in __init__
self.levelname = getLevelName(level)
RuntimeError: maximum recursion depth exceeded
Original exception was:
Traceback (most recent call last):
File "python/PyUtilModule/UserNodes.py", line 320, in _CustomNodeFactory
File "python/NodegraphAPI/NodeXmlIO.py", line 45, in LoadElementsFromFile
File "python/NodegraphAPI/NodegraphGlobals.py", line 138, in LoadXmlFromFile
File "python/NodegraphAPI/NodegraphGlobals.py", line 269, in _LoadXmlFromStream
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/tarfile.py", line 1683, in open
**kwargs)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/tarfile.py", line 1571, in __init__
self.firstmember = self.next()
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/tarfile.py", line 2314, in next
self.fileobj.seek(self.offset)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/tarfile.py", line 549, in seek
self.read(remainder)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/tarfile.py", line 568, in read
buf = self._read(size)
File "/opt/Foundry/Katana1.5v1b5/bin/python2.6/lib/python2.6/tarfile.py", line 575, in _read
if self.comptype == "tar":
RuntimeError: maximum recursion depth exceeded in cmp
Workaround
Avoid setting a macro’s user type to the macro’s own fully-suffixed name or the name of any other node type.
Reproduced by support
Katana 1.1v6 and 1.5v1b5, 1.6v3
Katana 2.5v1, 2.5v4 on Windows 7