From 6209a3a1de8f187c96e0ba1c871e97eb8717ed1e Mon Sep 17 00:00:00 2001 From: Graham Dumpleton Date: Thu, 12 Sep 2013 20:26:21 +1000 Subject: [PATCH] Only raise exception if no wrapped object if actually need to access it, else have issues in __new__() of derived class. --- src/_wrappers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_wrappers.c b/src/_wrappers.c index b0c4162..e5004b2 100644 --- a/src/_wrappers.c +++ b/src/_wrappers.c @@ -1013,11 +1013,6 @@ static PyObject *WraptObjectProxy_getattro( { PyObject *object = NULL; - if (!self->wrapped) { - PyErr_SetString(PyExc_ValueError, "wrapper has not been initialised"); - return NULL; - } - object = PyObject_GenericGetAttr((PyObject *)self, name); if (object) @@ -1025,6 +1020,11 @@ static PyObject *WraptObjectProxy_getattro( PyErr_Clear(); + if (!self->wrapped) { + PyErr_SetString(PyExc_ValueError, "wrapper has not been initialised"); + return NULL; + } + return PyObject_GetAttr(self->wrapped, name); }