If the code object creates a reference loop, this causes a reference leak. For example (see :
def f():
return 1234.5
code = f.__code__
a = []
code = code.replace(co_consts=code.co_consts + (a,))
a.append(code)
(See
|
def test_reference_loop_code(self): |
|
def f(): |
|
return 1234.5 |
|
code = f.__code__ |
|
a = [] |
|
code = code.replace(co_consts=code.co_consts + (a,)) |
|
a.append(code) |
added in
#148698)
This is because in the GIL-enabled build the code object does not support GC and does not have tp_traverse.
Linked PRs
If the code object creates a reference loop, this causes a reference leak. For example (see :
(See
cpython/Lib/test/test_marshal.py
Lines 354 to 360 in d61fcf8
This is because in the GIL-enabled build the code object does not support GC and does not have
tp_traverse.Linked PRs