Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: Changeset: r81493:9fbb68a334bc Date: 2015-12-30 00:27 +0100 http://bitbucket.org/pypy/pypy/changeset/9fbb68a334bc/
Log: Remove error=CANNOT_FAIL: if self.__getattribute__() fails, the exception must be propagated. This is the default for functions returning a PyObject*. diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -4,8 +4,7 @@ from rpython.rtyper.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( - cpython_api, generic_cpy_call, PyObject, Py_ssize_t, Py_TPFLAGS_CHECKTYPES, - CANNOT_FAIL) + cpython_api, generic_cpy_call, PyObject, Py_ssize_t, Py_TPFLAGS_CHECKTYPES) from pypy.module.cpyext.typeobjectdefs import ( unaryfunc, wrapperfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc, getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry, @@ -387,7 +386,7 @@ return @cpython_api([PyObject, PyObject], PyObject, - error=CANNOT_FAIL, external=True) + external=True) @func_renamer("cpyext_tp_getattro_%s" % (typedef.name,)) def slot_tp_getattro(space, w_self, w_name): return space.call_function(getattr_fn, w_self, w_name) diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -414,15 +414,26 @@ return NULL; } PyObject *name = PyString_FromString("attr1"); - PyIntObject *attr1 = obj->ob_type->tp_getattro(obj, name); - if (attr1->ob_ival != value->ob_ival) + PyIntObject *attr = obj->ob_type->tp_getattro(obj, name); + if (attr->ob_ival != value->ob_ival) { PyErr_SetString(PyExc_ValueError, "tp_getattro returned wrong value"); return NULL; } Py_DECREF(name); - Py_DECREF(attr1); + Py_DECREF(attr); + name = PyString_FromString("attr2"); + attr = obj->ob_type->tp_getattro(obj, name); + if (attr == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) + { + PyErr_Clear(); + } else { + PyErr_SetString(PyExc_ValueError, + "tp_getattro should have raised"); + return NULL; + } + Py_DECREF(name); Py_RETURN_TRUE; ''' ) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit