Skip to content

Commit 2abe435

Browse files
committed
test: add a test for the eval-leak fix
1 parent e2f0b64 commit 2abe435

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/test_oddball.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ def once(x): # line 301
206206
if fails > 8:
207207
pytest.fail("RAM grew by %d" % (ram_growth)) # pragma: only failure
208208

209+
def test_eval_codeobject_leak(self) -> None:
210+
code = """\
211+
for i in range(100_000):
212+
r = eval("'a' + '1'")
213+
assert r == 'a1'
214+
"""
215+
ram_0 = osinfo.process_ram()
216+
self.check_coverage(code, [1, 2, 3], "")
217+
ram_growth = osinfo.process_ram() - ram_0
218+
assert ram_growth < 2_000 * 1024
219+
209220

210221
class MemoryFumblingTest(CoverageTest):
211222
"""Test that we properly manage the None refcount."""

0 commit comments

Comments
 (0)