Bug report
Bug description:
TypeAliasType's traverse implementation does not visit its name. This means that we can leak memory if name is passed an instance of a mutable str subclass.
fromtypingimportTypeAliasTypeimportweakrefimportgcclassS(str):
passdefstill_alive(ref):
obj=ref()
ifnotisinstance(obj, S):
returnFalseT=obj.Tifnotisinstance(T, TypeAliasType):
returnFalsereturnTname=S("name")
T=TypeAliasType(name, int)
name.T=Tref=weakref.ref(name)
assertstill_alive(ref)
delnamedelTgc.collect()
gc.collect()
assertstill_alive(ref)
delref().Tassertnotstill_alive(ref)CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
TypeAliasType's traverse implementation does not visit its name. This means that we can leak memory if name is passed an instance of a mutable str subclass.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
nameattribute forTypeVar,TypeVarTuple,TypeAliasType,ParamSpec#140016nameattribute forTypeVar,TypeVarTuple,TypeAliasType,ParamSpec(GH-140016) #140063nameattribute forTypeVar,TypeVarTuple,TypeAliasType,ParamSpec(GH-140016) #140073