summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-18 18:46:23 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-18 18:46:23 (GMT)
commitb47ea9a6fef77a472665d21d04904f754dc7d55f (patch)
tree3172d7546b36db6a43e9e1591de354732f0d428a
parent05d79e9abfac38878298e4381c9166e58488664a (diff)
downloadcpython-b47ea9a6fef77a472665d21d04904f754dc7d55f.zip
cpython-b47ea9a6fef77a472665d21d04904f754dc7d55f.tar.gz
cpython-b47ea9a6fef77a472665d21d04904f754dc7d55f.tar.bz2
Issue #15615: Add some tests for the json module's handling of invalid input data.
Patch by Kushal Das.
-rw-r--r--Lib/test/json_tests/test_decode.py9
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
3 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/json_tests/test_decode.py b/Lib/test/json_tests/test_decode.py
index 9fbaa3b..4f7896e 100644
--- a/Lib/test/json_tests/test_decode.py
+++ b/Lib/test/json_tests/test_decode.py
@@ -54,6 +54,15 @@ class TestDecode:
self.check_keys_reuse(s, self.loads)
self.check_keys_reuse(s, self.json.decoder.JSONDecoder().decode)
+ def test_extra_data(self):
+ s = '[1, 2, 3]5'
+ msg = 'Extra data'
+ self.assertRaisesRegexp(ValueError, msg, self.loads, s)
+
+ def test_invalid_escape(self):
+ s = '["abc\\y"]'
+ msg = 'escape'
+ self.assertRaisesRegexp(ValueError, msg, self.loads, s)
class TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass
diff --git a/Misc/ACKS b/Misc/ACKS
index c3c59de..2e72f22 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -218,6 +218,7 @@ Evan Dandrea
Eric Daniel
Scott David Daniels
Ben Darnell
+Kushal Das
Jonathan Dasteel
John DeGood
Ned Deily
diff --git a/Misc/NEWS b/Misc/NEWS
index 8fdd515..86b178b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -425,6 +425,9 @@ Extension Modules
Tests
-----
+- Issue #15615: Add some tests for the json module's handling of invalid
+ input data. Patch by Kushal Das.
+
- Issue #15496: Add directory removal helpers for tests on Windows.
Patch by Jeremy Kloth.