summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-11-01 18:59:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-11-01 18:59:21 (GMT)
commit5ebe65f8cb541b10f07fb6ce2b4283a26c7e1d80 (patch)
treeeb43876e2c023c255b26cb6d79b188079f573f6f /Lib/test
parent90c0eb28c5ff1da76b258f9cf6a54abc6df19675 (diff)
parent9f69e79c450c3c17172046f937941e6df1802a6d (diff)
downloadcpython-5ebe65f8cb541b10f07fb6ce2b4283a26c7e1d80.zip
cpython-5ebe65f8cb541b10f07fb6ce2b4283a26c7e1d80.tar.gz
cpython-5ebe65f8cb541b10f07fb6ce2b4283a26c7e1d80.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')
-rw-r--r--Lib/test/json_tests/test_dump.py8
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