diff --git a/src/_wrappers.c b/src/_wrappers.c index e5004b2..2deb6d0 100644 --- a/src/_wrappers.c +++ b/src/_wrappers.c @@ -1040,11 +1040,6 @@ static int WraptObjectProxy_setattro( PyObject *match = NULL; - if (!self->wrapped) { - PyErr_SetString(PyExc_ValueError, "wrapper has not been initialised"); - return -1; - } - #if PY_MAJOR_VERSION >= 3 self_prefix = PyUnicode_FromString("_self_"); #else @@ -1077,6 +1072,11 @@ static int WraptObjectProxy_setattro( Py_DECREF(attr_wrapped); + if (!self->wrapped) { + PyErr_SetString(PyExc_ValueError, "wrapper has not been initialised"); + return -1; + } + #if PY_MAJOR_VERSION >= 3 attr_name = PyUnicode_FromString("__name__"); attr_qualname = PyUnicode_FromString("__qualname__");