diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-10 22:24:46 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-10 22:24:46 +0200 |
commit | 6df3ec19a81029ef035266a96505f814d8d6ccac (patch) | |
tree | c4933e54fc7f81b476c2ee904ebf20f050bb93ee /simplejson/_speedups.c | |
parent | 138a2ff3f6db37468f3c7509f69c984792fd49a0 (diff) | |
download | simplejson-6df3ec19a81029ef035266a96505f814d8d6ccac.tar.gz |
Make TypeError messages contain type name instead of a repr.
The failure depends on the type, not on the value of an object.
This combines CPython's issues 26623 and 24641.
Diffstat (limited to 'simplejson/_speedups.c')
-rw-r--r-- | simplejson/_speedups.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c index bfd053a..3d9e702 100644 --- a/simplejson/_speedups.c +++ b/simplejson/_speedups.c @@ -680,7 +680,9 @@ encoder_stringify_key(PyEncoderObject *s, PyObject *key) Py_INCREF(Py_None); return Py_None; } - 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); return NULL; } |