]> granicus.if.org Git - python/commitdiff
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can...
authorChristian Heimes <christian@cheimes.de>
Wed, 5 Dec 2007 12:49:14 +0000 (12:49 +0000)
committerChristian Heimes <christian@cheimes.de>
Wed, 5 Dec 2007 12:49:14 +0000 (12:49 +0000)
Objects/abstract.c
Objects/listobject.c

index 46288dd94114adbf7963f6116d440e631f8081f0..1cb4ef819a24873aeeb3e77bfd64969456cf96c6 100644 (file)
@@ -1507,8 +1507,9 @@ PySequence_Tuple(PyObject *v)
        /* Guess result size and allocate space. */
        n = _PyObject_LengthHint(v);
        if (n < 0) {
-               if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
-                   !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+               if (PyErr_Occurred()
+                   && !PyErr_ExceptionMatches(PyExc_TypeError)
+                   && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
                        Py_DECREF(it);
                        return NULL;
                }
index deb3ca5a02551428425cbe32963c581089d82611..8389a86ea713efa143269f3f80df71f91d4194b7 100644 (file)
@@ -796,8 +796,9 @@ listextend(PyListObject *self, PyObject *b)
        /* Guess a result list size. */
        n = _PyObject_LengthHint(b);
        if (n < 0) {
-               if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
-                   !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+               if (PyErr_Occurred()
+                   && !PyErr_ExceptionMatches(PyExc_TypeError)
+                   && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
                        Py_DECREF(it);
                        return NULL;
                }