| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9384665 commit aae498b
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,25 +80,23 @@ extern "C" { | |||
| 80 | 80 | ||
| 81 | 81 | This is the equivalent of the Python statement o.attr_name=v. */ | |
| 82 | 82 | ||
| 83 | - /* Implemented as a macro: | ||
| 83 | + /* Implemented elsewhere: | ||
| 84 | 84 | ||
| 85 | 85 | int PyObject_DelAttrString(PyObject *o, const char *attr_name); | |
| 86 | 86 | ||
| 87 | 87 | Delete attribute named attr_name, for object o. Returns | |
| 88 | 88 | -1 on failure. | |
| 89 | 89 | ||
| 90 | 90 | This is the equivalent of the Python statement: del o.attr_name. */ | |
| 91 | - #define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL) | ||
| 92 | 91 | ||
| 93 | 92 | ||
| 94 | - /* Implemented as a macro: | ||
| 93 | + /* Implemented elsewhere: | ||
| 95 | 94 | ||
| 96 | 95 | int PyObject_DelAttr(PyObject *o, PyObject *attr_name); | |
| 97 | 96 | ||
| 98 | 97 | Delete attribute named attr_name, for object o. Returns -1 | |
| 99 | 98 | on failure. This is the equivalent of the Python | |
| 100 | 99 | statement: del o.attr_name. */ | |
| 101 | - #define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL) | ||
| 102 | 100 | ||
| 103 | 101 | ||
| 104 | 102 | /* Implemented elsewhere: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -391,9 +391,11 @@ PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); | |||
| 391 | 391 | PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); | |
| 392 | 392 | PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); | |
| 393 | 393 | PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); | |
| 394 | + PyAPI_FUNC(int) PyObject_DelAttrString(PyObject *v, const char *name); | ||
| 394 | 395 | PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); | |
| 395 | 396 | PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); | |
| 396 | 397 | PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); | |
| 398 | + PyAPI_FUNC(int) PyObject_DelAttr(PyObject *v, PyObject *name); | ||
| 397 | 399 | PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); | |
| 398 | 400 | PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); | |
| 399 | 401 | PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Convert :c:func:`PyObject_DelAttr` and :c:func:`PyObject_DelAttrString` | ||
| 2 | + macros to functions. Patch by Victor Stinner. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2432,3 +2432,7 @@ | |||
| 2432 | 2432 | added = '3.13' | |
| 2433 | 2433 | [function.PyWeakref_GetRef] | |
| 2434 | 2434 | added = '3.13' | |
| 2435 | + [function.PyObject_DelAttr] | ||
| 2436 | + added = '3.13' | ||
| 2437 | + [function.PyObject_DelAttrString] | ||
| 2438 | + added = '3.13' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -942,6 +942,12 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w) | |||
| 942 | 942 | return res; | |
| 943 | 943 | } | |
| 944 | 944 | ||
| 945 | + int | ||
| 946 | + PyObject_DelAttrString(PyObject *v, const char *name) | ||
| 947 | + { | ||
| 948 | + return PyObject_SetAttrString(v, name, NULL); | ||
| 949 | + } | ||
| 950 | + | ||
| 945 | 951 | int | |
| 946 | 952 | _PyObject_IsAbstract(PyObject *obj) | |
| 947 | 953 | { | |
@@ -1185,6 +1191,12 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) | |||
| 1185 | 1191 | return -1; | |
| 1186 | 1192 | } | |
| 1187 | 1193 | ||
| 1194 | + int | ||
| 1195 | + PyObject_DelAttr(PyObject *v, PyObject *name) | ||
| 1196 | + { | ||
| 1197 | + return PyObject_SetAttr(v, name, NULL); | ||
| 1198 | + } | ||
| 1199 | + | ||
| 1188 | 1200 | PyObject ** | |
| 1189 | 1201 | _PyObject_ComputedDictPointer(PyObject *obj) | |
| 1190 | 1202 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1567,8 +1567,9 @@ static PyObject * | |||
| 1567 | 1567 | builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name) | |
| 1568 | 1568 | /*[clinic end generated code: output=85134bc58dff79fa input=164865623abe7216]*/ | |
| 1569 | 1569 | { | |
| 1570 | - if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0) | ||
| 1570 | + if (PyObject_DelAttr(obj, name) < 0) { | ||
| 1571 | 1571 | return NULL; | |
| 1572 | + } | ||
| 1572 | 1573 | Py_RETURN_NONE; | |
| 1573 | 1574 | } | |
| 1574 | 1575 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1240,7 +1240,7 @@ dummy_func( | |||
| 1240 | 1240 | ||
| 1241 | 1241 | inst(DELETE_ATTR, (owner --)) { | |
| 1242 | 1242 | PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); | |
| 1243 | - int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); | ||
| 1243 | + int err = PyObject_DelAttr(owner, name); | ||
| 1244 | 1244 | DECREF_INPUTS(); | |
| 1245 | 1245 | ERROR_IF(err, error); | |
| 1246 | 1246 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments