IronPython script ClosureCell type error

I have a relatively large (~5000 line) Python file of class and function definitions that I am trying to import into a Python script. I’m running Rhino 7 on Windows. When I attempt to run this file using either _RunPythonScript or _EditPythonScript, I get the following error message(with the repeating bit truncated):

Instance property 'Item070' is not defined for type 'Microsoft.Scripting.MutableTuple `2[Microsoft.Scripting.MutableTuple`128[IronPython.Runtime.ClosureCell, . . ., IronPython.Runtime.ClosureCell]]'

This error traces back to the import statement for the large file. As this happens as soon as the import, I cannot run debugging. From what I have gathered in the forums, ClosureCells are Rhino’s way of tracking IronPython pointers in the .NET space. I haven’t been able to find anything else.

I noticed this error when attempting to merge two fully-tested Git branches. Each works independently, and the code changes should not affect one another. Interestingly, when I remove a few variable definitions, the script runs with no errors. When I add a few new definitions of the sort a = 1 and b = 2, I get the same error again. Attempting to del a, b does not solve the problem.

Has anyone seen this error? My hunch is that I am running out of namespace memory for the IronPython debug within Rhino. Is this correct? Any suggestions for how to deal with this?

Hi Alex, Does the same error happen if you import it into regular Iron Python, or do you have Rhino / GH API calls in there preventing this by tripping a different error first?

Hello! The file I’m trying to import uses quite a bit of rhinoscriptsyntax, so I cannot run it outside of Rhino.

Ah never mind then. I found this person had a similar issue: python - IronPython Microsoft.Scripting.MutableTuple Exception - Stack Overflow so it can occur outside of Grasshopper too.

I’m not familiar with them, but can you just replace all the MutableTuples with a good old Python list, or is that going to require too much memory?

Good luck!

Thank you! I don’t have any MutableTuples in the code; from my understanding, these are artifacts of the interpreter. Upon further investigation, when I split the function definition into two functions, I am able to run with no errors. But I am unsatisfied with this error message and wish either IronPython or Rhino could be more descriptive of what is actually going on.