mirror of
https://github.com/python/cpython.git
synced 2026-05-08 11:31:13 +00:00
[3.14] gh-148653: Fix reference leaks in test_marshal introduced in gh-148698 (GH-148725) (GH-148727)
(cherry picked from commit 7ce737ea11)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
d496c637a3
commit
a37b105eec
1 changed files with 9 additions and 4 deletions
|
|
@ -357,6 +357,9 @@ def f():
|
|||
code = f.__code__
|
||||
a = []
|
||||
code = code.replace(co_consts=code.co_consts + (a,))
|
||||
# This test creates a reference loop which leads to reference leaks,
|
||||
# so we need to break the loop manually. See gh-148722.
|
||||
self.addCleanup(a.clear)
|
||||
a.append(code)
|
||||
for v in range(marshal.version + 1):
|
||||
self.assertRaises(ValueError, marshal.dumps, code, v)
|
||||
|
|
@ -404,10 +407,12 @@ def test_loads_abnormal_reference_loops(self):
|
|||
self.assertIs(a[0][None], a)
|
||||
|
||||
# Direct self-reference which cannot be created in Python.
|
||||
data = b'\xa8\x01\x00\x00\x00r\x00\x00\x00\x00' # (<R>,)
|
||||
a = marshal.loads(data)
|
||||
self.assertIsInstance(a, tuple)
|
||||
self.assertIs(a[0], a)
|
||||
# This creates a reference loop which cannot be collected.
|
||||
if False:
|
||||
data = b'\xa8\x01\x00\x00\x00r\x00\x00\x00\x00' # (<R>,)
|
||||
a = marshal.loads(data)
|
||||
self.assertIsInstance(a, tuple)
|
||||
self.assertIs(a[0], a)
|
||||
|
||||
# Direct self-references which cannot be created in Python
|
||||
# because of unhashability.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue