summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2024-03-18 12:24:24 (GMT)
committerGitHub <noreply@github.com>2024-03-18 12:24:24 (GMT)
commite2fcaf19d302b05d3466807bad0a61f39db2a51b (patch)
treeb1fe9e965596276acdec23d8075214ccb1039330 /Lib
parentcd2ed917801b93fb46d1dcf19dd480e5146932d8 (diff)
downloadcpython-e2fcaf19d302b05d3466807bad0a61f39db2a51b.zip
cpython-e2fcaf19d302b05d3466807bad0a61f39db2a51b.tar.gz
cpython-e2fcaf19d302b05d3466807bad0a61f39db2a51b.tar.bz2
gh-115874: Don't use module state in teedataobject tp_dealloc (#116204)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_itertools.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 9af0730..95e6791 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -1,7 +1,7 @@
import doctest
import unittest
from test import support
-from test.support import threading_helper
+from test.support import threading_helper, script_helper
from itertools import *
import weakref
from decimal import Decimal
@@ -1699,6 +1699,14 @@ class TestBasicOps(unittest.TestCase):
self.pickletest(proto, a, compare=ans)
self.pickletest(proto, b, compare=ans)
+ def test_tee_dealloc_segfault(self):
+ # gh-115874: segfaults when accessing module state in tp_dealloc.
+ script = (
+ "import typing, copyreg, itertools; "
+ "copyreg.buggy_tee = itertools.tee(())"
+ )
+ script_helper.assert_python_ok("-c", script)
+
# Issue 13454: Crash when deleting backward iterator from tee()
def test_tee_del_backward(self):
forward, backward = tee(repeat(None, 20000000))