diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-01 18:52:06 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-01 18:52:06 (GMT) |
commit | 9f69e79c450c3c17172046f937941e6df1802a6d (patch) | |
tree | 346e98946bad3a96f6a939ab6dfb2c53b81e00b2 /Lib | |
parent | 42d5c415224cf0bae36c74840b0d1c481f3ee99b (diff) | |
download | cpython-9f69e79c450c3c17172046f937941e6df1802a6d.zip cpython-9f69e79c450c3c17172046f937941e6df1802a6d.tar.gz cpython-9f69e79c450c3c17172046f937941e6df1802a6d.tar.bz2 |
Issue #16228: Fix a crash in the json module where a list changes size while it is being encoded.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/json_tests/test_dump.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/json_tests/test_dump.py b/Lib/test/json_tests/test_dump.py index 083c11f..fee972e 100644 --- a/Lib/test/json_tests/test_dump.py +++ b/Lib/test/json_tests/test_dump.py @@ -19,6 +19,14 @@ class TestDump: {2: 3.0, 4.0: 5, False: 1, 6: True}, sort_keys=True), '{"false": 1, "2": 3.0, "4.0": 5, "6": true}') + # Issue 16228: Crash on encoding resized list + def test_encode_mutated(self): + a = [object()] * 10 + def crasher(obj): + del a[-1] + self.assertEqual(self.dumps(a, default=crasher), + '[null, null, null, null, null]') + class TestPyDump(TestDump, PyTest): pass class TestCDump(TestDump, CTest): pass |