mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
Moved PyObject_{Get,Set}Attr to object.c.
Fixed two 'return NULL' that should be 'return -1'.
This commit is contained in:
parent
98ff96adba
commit
037b2205e8
1 changed files with 2 additions and 33 deletions
|
|
@ -926,37 +926,6 @@ PyTypeObject PyDict_Type = {
|
||||||
&dict_as_mapping, /*tp_as_mapping*/
|
&dict_as_mapping, /*tp_as_mapping*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/* These belong in object.c now */
|
|
||||||
|
|
||||||
PyObject *
|
|
||||||
PyObject_GetAttr(v, name)
|
|
||||||
PyObject *v;
|
|
||||||
PyObject *name;
|
|
||||||
{
|
|
||||||
if (v->ob_type->tp_getattro != NULL)
|
|
||||||
return (*v->ob_type->tp_getattro)(v, name);
|
|
||||||
else
|
|
||||||
return PyObject_GetAttrString(v, PyString_AsString(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
PyObject_SetAttr(v, name, value)
|
|
||||||
PyObject *v;
|
|
||||||
PyObject *name;
|
|
||||||
PyObject *value;
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
Py_INCREF(name);
|
|
||||||
PyString_InternInPlace(&name);
|
|
||||||
if (v->ob_type->tp_setattro != NULL)
|
|
||||||
err = (*v->ob_type->tp_setattro)(v, name, value);
|
|
||||||
else
|
|
||||||
err = PyObject_SetAttrString(
|
|
||||||
v, PyString_AsString(name), value);
|
|
||||||
Py_DECREF(name);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For backward compatibility with old dictionary interface */
|
/* For backward compatibility with old dictionary interface */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
|
@ -984,7 +953,7 @@ PyDict_SetItemString(v, key, item)
|
||||||
int err;
|
int err;
|
||||||
kv = PyString_FromString(key);
|
kv = PyString_FromString(key);
|
||||||
if (kv == NULL)
|
if (kv == NULL)
|
||||||
return NULL;
|
return -1;
|
||||||
PyString_InternInPlace(&kv);
|
PyString_InternInPlace(&kv);
|
||||||
err = PyDict_SetItem(v, kv, item);
|
err = PyDict_SetItem(v, kv, item);
|
||||||
Py_DECREF(kv);
|
Py_DECREF(kv);
|
||||||
|
|
@ -1000,7 +969,7 @@ PyDict_DelItemString(v, key)
|
||||||
int err;
|
int err;
|
||||||
kv = PyString_FromString(key);
|
kv = PyString_FromString(key);
|
||||||
if (kv == NULL)
|
if (kv == NULL)
|
||||||
return NULL;
|
return -1;
|
||||||
PyString_InternInPlace(&kv);
|
PyString_InternInPlace(&kv);
|
||||||
err = PyDict_DelItem(v, kv);
|
err = PyDict_DelItem(v, kv);
|
||||||
Py_DECREF(kv);
|
Py_DECREF(kv);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue