diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-25 02:40:21 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-25 02:40:21 (GMT) |
commit | 87e5006d8c5974597df9e3074b95227187d32be3 (patch) | |
tree | 82f8ff2dae761cdf19eeec36806f3bbb35b439e1 /Objects/abstract.c | |
parent | 176a56c69b1563c4a8ac0d8f974b4271177c80ee (diff) | |
download | cpython-87e5006d8c5974597df9e3074b95227187d32be3.zip cpython-87e5006d8c5974597df9e3074b95227187d32be3.tar.gz cpython-87e5006d8c5974597df9e3074b95227187d32be3.tar.bz2 |
handle errors from _PyObject_LookupSpecial when __get__ fails
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 63b2041..5eb7b28 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -111,8 +111,12 @@ _PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue) return defaultvalue; /* try o.__length_hint__() */ hintmeth = _PyObject_LookupSpecial(o, "__length_hint__", &hintstrobj); - if (hintmeth == NULL) - return defaultvalue; + if (hintmeth == NULL) { + if (PyErr_Occurred()) + return -1; + else + return defaultvalue; + } ro = PyObject_CallFunctionObjArgs(hintmeth, NULL); Py_DECREF(hintmeth); if (ro == NULL) { @@ -2945,6 +2949,8 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls) } return ok; } + else if (PyErr_Occurred()) + return -1; } return recursive_isinstance(inst, cls); } @@ -3021,6 +3027,9 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls) } return ok; } + else if (PyErr_Occurred()) { + return -1; + } } return recursive_issubclass(derived, cls); } |