summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2023-08-27 00:13:33 (GMT)
committerGitHub <noreply@github.com>2023-08-27 00:13:33 (GMT)
commit482fad7f01567447b7259ebf58d62999fcdc5964 (patch)
treecee619319091ab69b76b61c4ead8a740c82523c1 /Lib/test
parent2b15536fa94d07e9e286826c23507402313ec7f4 (diff)
downloadcpython-482fad7f01567447b7259ebf58d62999fcdc5964.zip
cpython-482fad7f01567447b7259ebf58d62999fcdc5964.tar.gz
cpython-482fad7f01567447b7259ebf58d62999fcdc5964.tar.bz2
gh-108295: Fix crashes with TypeVar weakrefs (#108517)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_typing.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 38baf95..6447ed6 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -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.