diff options
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r-- | Objects/weakrefobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index c36d2395cc..bb56c7dbdb 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -657,6 +657,12 @@ proxy_iternext(PyWeakReference *proxy) return NULL; PyObject *obj = PyWeakref_GET_OBJECT(proxy); + if (!PyIter_Check(obj)) { + PyErr_Format(PyExc_TypeError, + "Weakref proxy referenced a non-iterator '%.200s' object", + Py_TYPE(obj)->tp_name); + return NULL; + } Py_INCREF(obj); PyObject* res = PyIter_Next(obj); Py_DECREF(obj); |