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.
This commit is contained in:
Serhiy Storchaka 2017-11-25 17:38:20 +02:00 committed by GitHub
parent 5b48dc638b
commit cfa797c068
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 13 deletions

View file

@ -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;
}