diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-01 19:03:30 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-01 19:03:30 (GMT) |
commit | 53d36b691241f278fa6173034e6edb10154e62d3 (patch) | |
tree | 4dc522e53a8ab1f0c6f1cf24b0aeea5e9c0528b9 /Lib/test/json_tests/test_dump.py | |
parent | 1511a5a3af26c99d73ae2933c74aed25ad1e8722 (diff) | |
parent | 5ebe65f8cb541b10f07fb6ce2b4283a26c7e1d80 (diff) | |
download | cpython-53d36b691241f278fa6173034e6edb10154e62d3.zip cpython-53d36b691241f278fa6173034e6edb10154e62d3.tar.gz cpython-53d36b691241f278fa6173034e6edb10154e62d3.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/test/json_tests/test_dump.py')
-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 4b3386f..237ee35 100644 --- a/Lib/test/json_tests/test_dump.py +++ b/Lib/test/json_tests/test_dump.py @@ -20,6 +20,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 |