Skip to content

Commit bb6777b

Browse files
committed
Move the check
1 parent 3b78e5b commit bb6777b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Objects/object.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,17 +1213,17 @@ PyObject_HasAttrString(PyObject *obj, const char *name)
12131213
int
12141214
PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
12151215
{
1216-
if (Py_TYPE(v)->tp_setattr != NULL) {
1217-
PyThreadState *tstate = _PyThreadState_GET();
1218-
if (w == NULL && _PyErr_Occurred(tstate)) {
1219-
PyObject *exc = _PyErr_GetRaisedException(tstate);
1220-
_PyErr_SetString(tstate, PyExc_SystemError,
1221-
"PyObject_SetAttrString() must not be called with NULL value "
1222-
"and an exception set");
1223-
_PyErr_ChainExceptions1Tstate(tstate, exc);
1224-
return -1;
1225-
}
1216+
PyThreadState *tstate = _PyThreadState_GET();
1217+
if (w == NULL && _PyErr_Occurred(tstate)) {
1218+
PyObject *exc = _PyErr_GetRaisedException(tstate);
1219+
_PyErr_SetString(tstate, PyExc_SystemError,
1220+
"PyObject_SetAttrString() must not be called with NULL value "
1221+
"and an exception set");
1222+
_PyErr_ChainExceptions1Tstate(tstate, exc);
1223+
return -1;
1224+
}
12261225

1226+
if (Py_TYPE(v)->tp_setattr != NULL) {
12271227
return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w);
12281228
}
12291229

0 commit comments

Comments
 (0)