Index: Lib/json/tests/test_fail.py =================================================================== --- Lib/json/tests/test_fail.py (revision 82985) +++ Lib/json/tests/test_fail.py (working copy) @@ -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) Index: Modules/_json.c =================================================================== --- Modules/_json.c (revision 82985) +++ Modules/_json.c (working copy) @@ -1454,7 +1454,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; }