[Python-checkins] r83018 - in python/branches/release27-maint: Lib/json/tests/test_fail.py Modules/_json.c
doug.hellmann
python-checkins at python.org
Wed Jul 21 14:36:33 CEST 2010
Author: doug.hellmann
Date: Wed Jul 21 14:36:33 2010
New Revision: 83018
Log:
Apply patch from Ray Allen for issue 9296
Modified:
python/branches/release27-maint/Lib/json/tests/test_fail.py
python/branches/release27-maint/Modules/_json.c
Modified: python/branches/release27-maint/Lib/json/tests/test_fail.py
==============================================================================
--- python/branches/release27-maint/Lib/json/tests/test_fail.py (original)
+++ python/branches/release27-maint/Lib/json/tests/test_fail.py Wed Jul 21 14:36:33 2010
@@ -74,3 +74,12 @@
pass
else:
self.fail("Expected failure for fail{0}.json: {1!r}".format(idx, doc))
+
+ def test_non_string_keys_dict(self):
+ data = {'a' : 1, (1, 2) : 2}
+
+ #This is for c encoder
+ self.assertRaises(TypeError, json.dumps, data)
+
+ #This is for python encoder
+ self.assertRaises(TypeError, json.dumps, data, indent=True)
Modified: python/branches/release27-maint/Modules/_json.c
==============================================================================
--- python/branches/release27-maint/Modules/_json.c (original)
+++ python/branches/release27-maint/Modules/_json.c Wed Jul 21 14:36:33 2010
@@ -2147,7 +2147,7 @@
}
else {
/* TODO: include repr of key */
- PyErr_SetString(PyExc_ValueError, "keys must be a string");
+ PyErr_SetString(PyExc_TypeError, "keys must be a string");
goto bail;
}
More information about the Python-checkins
mailing list