Only raise exception if no wrapped object if actually need to access it to set an attribute.

This commit is contained in:
Graham Dumpleton
2013-09-12 20:27:06 +10:00
parent 6209a3a1de
commit af9131ba96

View File

@@ -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__");