Crash report
What happened?
gh-108517 (fix for gh-108295) added PyObject_ClearWeakRefs() to typevar_dealloc, paramspec_dealloc, and typevartuple_dealloc, but missed paramspecattr_dealloc(). Both paramspecargs_spec and paramspeckwargs_spec set Py_TPFLAGS_MANAGED_WEAKREF, so the same crash from gh-108295 still occurs for ParamSpec(...).args and ParamSpec(...).kwargs.
import weakref
from typing import ParamSpec, TypeVar
def probe(label, make):
obj = make()
fired = []
r = weakref.ref(obj, lambda ref: fired.append(True))
del obj
print(f" {label:16s} callback_fired={bool(fired)!s:5s}")
del r
probe("TypeVar", lambda: TypeVar("T")) # Works fine
probe("ParamSpecArgs", lambda: ParamSpec("P").args) # segfault
CPython versions tested on:
3.12, 3.13, 3.14, 3.15, 3.16, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs
Crash report
What happened?
gh-108517 (fix for gh-108295) added
PyObject_ClearWeakRefs()totypevar_dealloc,paramspec_dealloc, andtypevartuple_dealloc, but missedparamspecattr_dealloc(). Bothparamspecargs_specandparamspeckwargs_specsetPy_TPFLAGS_MANAGED_WEAKREF, so the same crash from gh-108295 still occurs forParamSpec(...).argsandParamSpec(...).kwargs.CPython versions tested on:
3.12, 3.13, 3.14, 3.15, 3.16, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs