Skip to content

SystemError for pep695 type parameter with the same name as the inner class #109219

Description

@15r10nk

Bug report

Bug description:

The following script shows the SystemError:

classname_1[name_4]:
classname_4[name_2](name_4):
name_4

output (Python 3.12.0rc2+):

SystemError: compiler_lookup_arg(name='name_4') withreftype=3failedin<genericparametersofname_4>; freevarsofcodename_4: ('.type_params', 'name_4')

minimizing it further leads some different crashes:
The propably most interresting one is this, which does not look special at all.

classname_1[name_3]:
classname_4[name_2](name_5):
pass

output (Python 3.12.0rc2+):

Traceback (mostrecentcalllast):
File"/home/frank/projects/pysource-codegen/bug3.py", line1, in<module>classname_1[name_3]:
File"/home/frank/projects/pysource-codegen/bug3.py", line1, in<genericparametersofname_1>classname_1[name_3]:
File"/home/frank/projects/pysource-codegen/bug3.py", line2, inname_1classname_4[name_2](name_5):
File"/home/frank/projects/pysource-codegen/bug3.py", line2, in<genericparametersofname_4>classname_4[name_2](name_5):
^^^^^^NameError: name'name_5'isnotdefined. Didyoumean: 'name_2'?
Modules/gcmodule.c:113: gc_decref: Assertion"gc_get_refs(g) > 0"failed: refcountistoosmallEnabletracemalloctogetthememoryblockallocationtracebackobjectaddress : 0x7f2c57a12930objectrefcount : 1objecttype : 0x557ad9ef1fe0objecttypename: dictobjectrepr : {'__module__': '__main__', '__qualname__': 'name_1', '__type_params__': (name_3,)}
FatalPythonerror: _PyObject_AssertFailed: _PyObject_AssertFailedPythonruntimestate: finalizing (tstate=0x0000557ada04eba0)
Currentthread0x00007f2c57f21280 (mostrecentcallfirst):
Garbage-collecting<noPythonframe>

@JelleZijlstra I think this is another one for you. Feel free to create a second issue if you think that they are unrelated.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions