summaryrefslogtreecommitdiff
path: root/Modules/_json.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-11-25 17:38:20 +0200
committerGitHub <noreply@github.com>2017-11-25 17:38:20 +0200
commitcfa797c0681b7fef47cf93955fd06b54ddd09a7f (patch)
tree6e4ecf5ed329d339b26f1eb2bf1f73950abbee72 /Modules/_json.c
parent5b48dc638b7405fd9bde4d854bf477dfeaaddf44 (diff)
downloadcpython-git-cfa797c0681b7fef47cf93955fd06b54ddd09a7f.tar.gz
bpo-24641: Improved error message for JSON unserializible keys. (#4364)
Also updated an example for default() in the module docstring. Removed quotes around type name in other error messages.
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 13218a6ecc..5a9464e34f 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1650,8 +1650,9 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
continue;
}
else {
- /* TODO: include repr of key */
- PyErr_SetString(PyExc_TypeError, "keys must be a string");
+ PyErr_Format(PyExc_TypeError,
+ "keys must be str, int, float, bool or None, "
+ "not %.100s", key->ob_type->tp_name);
goto bail;
}