mirror of
https://github.com/python/cpython.git
synced 2025-08-08 19:09:46 +00:00
[3.12] gh-108295: Fix crashes with TypeVar weakrefs (GH-108517) (#108527)
gh-108295: Fix crashes with TypeVar weakrefs (GH-108517)
(cherry picked from commit 482fad7f01
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
3e20303717
commit
09877a15d5
3 changed files with 14 additions and 0 deletions
|
@ -544,6 +544,16 @@ class TypeVarTests(BaseTestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
list[T][arg]
|
||||
|
||||
def test_many_weakrefs(self):
|
||||
# gh-108295: this used to segfault
|
||||
for cls in (ParamSpec, TypeVarTuple, TypeVar):
|
||||
with self.subTest(cls=cls):
|
||||
vals = weakref.WeakValueDictionary()
|
||||
|
||||
for x in range(100000):
|
||||
vals[x] = cls(str(x))
|
||||
del vals
|
||||
|
||||
|
||||
def template_replace(templates: list[str], replacements: dict[str, list[str]]) -> list[tuple[str]]:
|
||||
"""Renders templates with possible combinations of replacements.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue