From df71dcbef212d0800c428532872d32727c58776b Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 26 Jun 2014 23:27:41 -0700 Subject: [PATCH] don't overwrite the error from PyObject_GetAttrString (closes #4346) --- Misc/NEWS | 3 +++ Objects/abstract.c | 12 ++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 66c558a267..4f86a51fcf 100644 --- 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. diff --git a/Objects/abstract.c b/Objects/abstract.c index 3c88711663..5707eb2b88 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -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); -- 2.50.1