]> granicus.if.org Git - python/commitdiff
Issue #15615: Add some tests for the json module's handling of invalid input data.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 18 Aug 2012 18:46:23 +0000 (20:46 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 18 Aug 2012 18:46:23 +0000 (20:46 +0200)
Patch by Kushal Das.

Lib/test/json_tests/test_decode.py
Misc/ACKS
Misc/NEWS

index 9fbaa3bdf89ba067374f863f0f9483ec46d9a706..4f7896e21fe398e98a4639f3c9d61a50fe23c810 100644 (file)
@@ -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
index c3c59dee29d638949a574261ebd767f4c540e6b8..2e72f22592cd9dbad4d5f92c13648058a1320627 100644 (file)
--- 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
index 8fdd51534c2cae961997d51a8289fc27dec89337..86b178b64c1b4b2d92be8483237bb8c62953a7cb 100644 (file)
--- 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.