summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2021-08-23 20:56:21 -0700
committerGitHub <noreply@github.com>2021-08-23 20:56:21 -0700
commit6eeec11fcebf80c314e3a408897ac6c811153f24 (patch)
tree38d79d362e5ff641022a9a3fd7e7f2e0b0bee8d1
parent47d5aa05376670a7eea1f9118fda3c7f8c98c022 (diff)
downloadsimplejson-6eeec11fcebf80c314e3a408897ac6c811153f24.tar.gz
Raise TypeError when _asdict() is callable but does not return a dict
-rw-r--r--simplejson/_speedups.c5
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;
}