]> granicus.if.org Git - python/commitdiff
don't overwrite the error from PyObject_GetAttrString (closes #4346)
authorBenjamin Peterson <benjamin@python.org>
Fri, 27 Jun 2014 06:27:41 +0000 (23:27 -0700)
committerBenjamin Peterson <benjamin@python.org>
Fri, 27 Jun 2014 06:27:41 +0000 (23:27 -0700)
Misc/NEWS
Objects/abstract.c

index 66c558a267bb0747bd994d48522f1bf766881c58..4f86a51fcf2e6c85adf31b64014f04a20bca4517 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 2.7.8?
 Core and Builtins
 -----------------
 
+- Issue #4346: In PyObject_CallMethod and PyObject_CallMethodObjArgs, don't
+  overwrite the error set in PyObject_GetAttr.
+
 - Issue #21831: Avoid integer overflow when large sizes and offsets are given to
   the buffer type.
 
index 3c8871166367a98768c36606050609d5f270ab49..5707eb2b8833c70c953b1711592246b1546b2d15 100644 (file)
@@ -2617,10 +2617,8 @@ PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
         return null_error();
 
     func = PyObject_GetAttrString(o, name);
-    if (func == NULL) {
-        PyErr_SetString(PyExc_AttributeError, name);
-        return 0;
-    }
+    if (func == NULL)
+        return NULL;
 
     if (!PyCallable_Check(func)) {
         type_error("attribute of type '%.200s' is not callable", func);
@@ -2656,10 +2654,8 @@ _PyObject_CallMethod_SizeT(PyObject *o, char *name, char *format, ...)
         return null_error();
 
     func = PyObject_GetAttrString(o, name);
-    if (func == NULL) {
-        PyErr_SetString(PyExc_AttributeError, name);
-        return 0;
-    }
+    if (func == NULL)
+        return NULL;
 
     if (!PyCallable_Check(func)) {
         type_error("attribute of type '%.200s' is not callable", func);