So I have this code which has some functions. These functions return a long string, which is basically constructed by concatenation. For example:
def myFunc(): file = "" file = file + "text1\n" file = file + " newText\n" [....] file = file + "exit\n" return file
Now, this works ok if I call it via CLI, such as python3 myProg.py
. So far, so good.
But if I try to compile this code, I get this error:
python3 -m nuitka myProg.py --nofollow-import-to=MySQLdb --nofollow-import-to=time --nofollow-import-to=os --nofollow-import-to=sys --nofollow-import-to=shutil --nofollow-import-to=zipfile --nofollow-import-to=pandas --follow-imports Nuitka:INFO: Starting Python compilation. Problem with statement at /home/lucas/myProg/templates/module1.py:1778: -> out = file Problem with statement at /home/lucas/myProg/templates/module1.py:629: -> def myFunc(): Problem with statement at /home/lucas/myProg/templates/module1.py:629: -> def myFunc(): Nuitka:INFO: Interrupted while working on '<Node 'COMPILED_PYTHON_MODULE' with {'code_flags': '', 'module_name': <ModuleName templates.module1>, 'filename': '/home/lucas/myProg/templates/module1.py'}>'. Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/nuitka/MainControl.py", line 149, in createNodeTree Optimization.optimize(main_module.getOutputFilename()) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/Optimization.py", line 625, in optimize makeOptimizationPass() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/Optimization.py", line 537, in makeOptimizationPass changed = optimizeModule(current_module) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/Optimization.py", line 185, in optimizeModule changed = optimizeCompiledPythonModule(module) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/Optimization.py", line 106, in optimizeCompiledPythonModule module.computeModule() File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/ModuleNodes.py", line 509, in computeModule trace_collection=self.trace_collection File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/StatementNodes.py", line 165, in computeStatementsSequence new_statement = statement.computeStatementsSequence(trace_collection) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/FrameNodes.py", line 182, in computeStatementsSequence new_statement = trace_collection.onStatement(statement=statement) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 507, in onStatement new_statement, change_tags, change_desc = statement.computeStatement(self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/AssignNodes.py", line 278, in computeStatement source = trace_collection.onExpression(self.subnode_source) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 488, in onExpression r = expression.computeExpressionRaw(trace_collection=self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/ExpressionBases.py", line 1060, in computeExpressionRaw expression = trace_collection.onExpression(sub_expression) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 488, in onExpression r = expression.computeExpressionRaw(trace_collection=self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/FunctionNodes.py", line 953, in computeExpressionRaw function_body.computeFunctionRaw(trace_collection) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/FunctionNodes.py", line 433, in computeFunctionRaw self.computeFunction(trace_collection) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/FunctionNodes.py", line 449, in computeFunction trace_collection=trace_collection File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/StatementNodes.py", line 167, in computeStatementsSequence new_statement = trace_collection.onStatement(statement=statement) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 507, in onStatement new_statement, change_tags, change_desc = statement.computeStatement(self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/TryNodes.py", line 126, in computeStatement exception_collections = trace_collection.getExceptionRaiseCollections() File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__ self.gen.throw(type, value, traceback) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 219, in makeAbortStackContext yield File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/TryNodes.py", line 112, in computeStatement result = tried.computeStatementsSequence(trace_collection=trace_collection) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/StatementNodes.py", line 165, in computeStatementsSequence new_statement = statement.computeStatementsSequence(trace_collection) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/FrameNodes.py", line 182, in computeStatementsSequence new_statement = trace_collection.onStatement(statement=statement) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 507, in onStatement new_statement, change_tags, change_desc = statement.computeStatement(self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/AssignNodes.py", line 278, in computeStatement source = trace_collection.onExpression(self.subnode_source) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 488, in onExpression r = expression.computeExpressionRaw(trace_collection=self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/ExpressionBases.py", line 1060, in computeExpressionRaw expression = trace_collection.onExpression(sub_expression) File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/TraceCollections.py", line 488, in onExpression r = expression.computeExpressionRaw(trace_collection=self) File "/usr/local/lib/python3.5/dist-packages/nuitka/nodes/VariableRefNodes.py", line 432, in computeExpressionRaw self.variable_trace.addUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 301, in addUsage self.previous.addNameUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 96, in addNameUsage self.previous.addNameUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 96, in addNameUsage self.previous.addNameUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 96, in addNameUsage self.previous.addNameUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 96, in addNameUsage self.previous.addNameUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 96, in addNameUsage self.previous.addNameUsage() File "/usr/local/lib/python3.5/dist-packages/nuitka/optimizations/ValueTraces.py", line 95, in addNameUsage if self.name_usage_count <= 2 and self.previous is not None: RecursionError: maximum recursion depth exceeded in comparison
What I have seen, is the following: if I shorten the concatenation, I can compile without problems, meaning reducing the number of file = file + " blabla"
.
In total, I have 1140 concatenations inside myFunc()
.
I've read that using sys.setrecursionlimit()
might help. I had it at 3000; set it a 8000, but it is not compiling either. The only solution so far, is shortening the concatenation, which for the purpose of testing it's ok, but not for the proper functioning of my code.
Any ideas on how to overcome this?
Thanks!
https://stackoverflow.com/questions/65546271/nuitka-fails-to-compile-python-interpreter-works-ok-recursion-error January 03, 2021 at 11:03AM
没有评论:
发表评论