Kaydet (Commit) 1859f5b4 authored tarafından Guido van Rossum's avatar Guido van Rossum

Backport r60246.

Fix issue #1303614, test67.py.
üst 61c2c953
...@@ -1335,12 +1335,15 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) ...@@ -1335,12 +1335,15 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
dictptr = (PyObject **) ((char *)obj + dictoffset); dictptr = (PyObject **) ((char *)obj + dictoffset);
dict = *dictptr; dict = *dictptr;
if (dict != NULL) { if (dict != NULL) {
Py_INCREF(dict);
res = PyDict_GetItem(dict, name); res = PyDict_GetItem(dict, name);
if (res != NULL) { if (res != NULL) {
Py_INCREF(res); Py_INCREF(res);
Py_XDECREF(descr); Py_XDECREF(descr);
Py_DECREF(dict);
goto done; goto done;
} }
Py_DECREF(dict);
} }
} }
...@@ -1421,12 +1424,14 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) ...@@ -1421,12 +1424,14 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
*dictptr = dict; *dictptr = dict;
} }
if (dict != NULL) { if (dict != NULL) {
Py_INCREF(dict);
if (value == NULL) if (value == NULL)
res = PyDict_DelItem(dict, name); res = PyDict_DelItem(dict, name);
else else
res = PyDict_SetItem(dict, name, value); res = PyDict_SetItem(dict, name, value);
if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
PyErr_SetObject(PyExc_AttributeError, name); PyErr_SetObject(PyExc_AttributeError, name);
Py_DECREF(dict);
goto done; goto done;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment