Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Closed
Description
Bug report
Bug description:
The following code causes a SystemError during compilation.
classname_2[*name_5,name_3:int]: (name_3:=name_4)classname_4[name_5:name_5]((name_4forname_5inname_0ifname_3),name_2ifname_3elsename_0):pass
output (Python 3.12.0rc2+):
SystemError:compiler_lookup_arg(name='name_3')withreftype=3failedin<genericparametersofname_4>;freevarsofcode<genexpr>: ('name_3',)
removing the named-expression makes it worse and causes a crash
classname_2[*name_5,name_3:int]:classname_4[name_5:name_5]((name_4forname_5inname_0ifname_3),name_2ifname_3elsename_0):pass
output (Python 3.12.0rc2+):
Traceback (mostrecentcalllast):File"/home/frank/projects/pysource-codegen/bug2.py",line2,in<module>classname_2[*name_5,name_3:int]:File"/home/frank/projects/pysource-codegen/bug2.py",line2,in<genericparametersofname_2>classname_2[*name_5,name_3:int]:File"/home/frank/projects/pysource-codegen/bug2.py",line4,inname_2classname_4[name_5:name_5]((name_4forname_5inname_0ifname_3),name_2ifname_3elsename_0):File"/home/frank/projects/pysource-codegen/bug2.py",line4,in<genericparametersofname_4>classname_4[name_5:name_5]((name_4forname_5inname_0ifname_3),name_2ifname_3elsename_0):^^^^^^NameError:name'name_0'isnotdefinedModules/gcmodule.c:113:gc_decref:Assertion"gc_get_refs(g) > 0"failed:refcountistoosmallEnabletracemalloctogetthememoryblockallocationtracebackobjectaddress :0x7f4c77059a30objectrefcount :1objecttype :0x560ea4b6cfe0objecttypename:dictobjectrepr : {'__module__':'__main__','__qualname__':'name_2','__type_params__': (name_5,name_3)}FatalPythonerror:_PyObject_AssertFailed:_PyObject_AssertFailedPythonruntimestate:finalizing (tstate=0x0000560ea4cc9ba0)Currentthread0x00007f4c7756c280 (mostrecentcallfirst):Garbage-collecting<noPythonframe>
side note:
The reason for the strange looking language constructs and variable names is that I generated this code. I found it while working on my pysource-codegen library.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
- gh-109118: Fix runtime crash when NameError happens in PEP 695 function #109123
- [3.12] gh-109118: Fix runtime crash when NameError happens in PEP 695 function (GH-109123) #109173
- gh-109118: Disallow nested scopes within PEP 695 scopes within classes #109196
- [3.12] gh-109118: Disallow nested scopes within PEP 695 scopes within classes (GH-109196) #109297
- gh-109118: Allow lambdas in annotation scopes in classes #118019
- gh-109118: Make comprehensions work within annotation scopes, but without inlining #118160
Metadata
Metadata
Assignees
Projects
Status
Done