Nested function and class nonlocal usage triggers unexpected internal exception
The following code triggers an unexpected internal exception:
def foo():
var = 0
class A:
def wrapper():
nonlocal var
var = 1
wrapper()
nonlocal var
print(var)
foo()
RPython traceback:
File "pypy_interpreter.c", line 37022, in BuiltinCode_funcrun_obj
File "pypy_module___builtin__.c", line 3232, in compile
File "pypy_interpreter.c", line 56391, in PythonAstCompiler__compile_ast
File "pypy_interpreter_astcompiler.c", line 1679, in compile_ast
File "implement_2.c", line 27470, in dispatcher_81
File "pypy_interpreter_astcompiler.c", line 25013, in PythonCodeGenerator__handle_body
File "pypy_interpreter_astcompiler_2.c", line 26304, in PythonCodeGenerator_visit_FunctionDef
File "pypy_interpreter_astcompiler_2.c", line 46076, in _visit_function__FunctionCodeGenerator
File "pypy_interpreter_astcompiler_2.c", line 44308, in PythonCodeGenerator_sub_scope
File "pypy_interpreter_astcompiler_3.c", line 29114, in FunctionCodeGenerator__compile
File "pypy_interpreter_astcompiler_2.c", line 22868, in PythonCodeGenerator_visit_ClassDef
File "pypy_interpreter_astcompiler_2.c", line 44308, in PythonCodeGenerator_sub_scope
File "pypy_interpreter_astcompiler_2.c", line 19627, in ClassCodeGenerator__compile
File "pypy_interpreter_astcompiler.c", line 25013, in PythonCodeGenerator__handle_body
File "pypy_interpreter_astcompiler_2.c", line 26304, in PythonCodeGenerator_visit_FunctionDef
File "pypy_interpreter_astcompiler_2.c", line 46092, in _visit_function__FunctionCodeGenerator
File "pypy_interpreter_astcompiler_2.c", line 45035, in PythonCodeGenerator__make_function
SystemError: unexpected internal exception (please report a bug): <KeyError object at 0x7f614c2f0da8>; internal traceback was dumped to stderr
Version info:
Python 3.7.9 (7e6e2bb30ac5, Nov 18 2020, 10:55:52)
[PyPy 7.3.3-beta0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information