mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Apply patch from Ray Allen for issue 9296
This commit is contained in:
parent
8c4fa11591
commit
f31db93fc1
2 changed files with 10 additions and 1 deletions
|
|
@ -74,3 +74,12 @@ class TestFail(TestCase):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.fail("Expected failure for fail{0}.json: {1!r}".format(idx, doc))
|
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)
|
||||||
|
|
|
||||||
|
|
@ -2147,7 +2147,7 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* TODO: include repr of key */
|
/* 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;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue