diff options
author | Bob Ippolito <bob@redivi.com> | 2021-08-23 20:56:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-23 20:56:21 -0700 |
commit | 6eeec11fcebf80c314e3a408897ac6c811153f24 (patch) | |
tree | 38d79d362e5ff641022a9a3fd7e7f2e0b0bee8d1 /simplejson/_speedups.c | |
parent | 47d5aa05376670a7eea1f9118fda3c7f8c98c022 (diff) | |
download | simplejson-6eeec11fcebf80c314e3a408897ac6c811153f24.tar.gz |
Raise TypeError when _asdict() is callable but does not return a dict
Diffstat (limited to 'simplejson/_speedups.c')
-rw-r--r-- | simplejson/_speedups.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c index ef0dc6b..6fefa99 100644 --- a/simplejson/_speedups.c +++ b/simplejson/_speedups.c @@ -2856,6 +2856,11 @@ encoder_listencode_obj(PyEncoderObject *s, JSON_Accu *rval, PyObject *obj, Py_ss newobj = PyObject_CallMethod(obj, "_asdict", NULL); if (newobj != NULL) { if (!PyDict_Check(newobj)) { + PyErr_Format( + PyExc_TypeError, + "_asdict() must return a dict, not %.80s", + Py_TYPE(newobj)->tp_name + ); Py_DECREF(newobj); return -1; } |