summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-18 18:48:17 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-18 18:48:17 (GMT)
commitdbcae3c1917228b6776cb132d552766df7937f74 (patch)
treecade30ec0aa12e63764aef2e5ae11d12ff6b24ac
parent35fa864840c7ab56acc474b6c035fdc6ae9005a3 (diff)
parentb47ea9a6fef77a472665d21d04904f754dc7d55f (diff)
downloadcpython-dbcae3c1917228b6776cb132d552766df7937f74.zip
cpython-dbcae3c1917228b6776cb132d552766df7937f74.tar.gz
cpython-dbcae3c1917228b6776cb132d552766df7937f74.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/NEWS5
3 files changed, 15 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 6e2a20a..b412fa1 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -238,6 +238,7 @@ Evan Dandrea
Eric Daniel
Scott David Daniels
Ben Darnell
+Kushal Das
Jonathan Dasteel
Pierre-Yves David
Xavier de Gaye
diff --git a/Misc/NEWS b/Misc/NEWS
index a40d129..3b7576c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,11 @@ Documentation
- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
Daniel Ellis.
+Tests
+-----
+
+- Issue #15615: Add some tests for the json module's handling of invalid
+ input data. Patch by Kushal Das.
What's New in Python 3.3.0 Beta 2?