mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
bpo-39465: Don't access directly _Py_Identifier members (GH-20043)
* Replace id->object with _PyUnicode_FromId(&id) * Use _Py_static_string_init(str) macro to initialize statically name_op in typeobject.c.
This commit is contained in:
parent
27c0d9b54a
commit
4804b5b3df
4 changed files with 11 additions and 11 deletions
|
@ -2287,7 +2287,7 @@ method_output_as_list(PyObject *o, _Py_Identifier *meth_id)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s.%U() returned a non-iterable (type %.200s)",
|
||||
Py_TYPE(o)->tp_name,
|
||||
meth_id->object,
|
||||
_PyUnicode_FromId(meth_id),
|
||||
Py_TYPE(meth_output)->tp_name);
|
||||
}
|
||||
Py_DECREF(meth_output);
|
||||
|
|
|
@ -1519,7 +1519,7 @@ lookup_method(PyObject *self, _Py_Identifier *attrid, int *unbound)
|
|||
{
|
||||
PyObject *res = lookup_maybe_method(self, attrid, unbound);
|
||||
if (res == NULL && !PyErr_Occurred()) {
|
||||
PyErr_SetObject(PyExc_AttributeError, attrid->object);
|
||||
PyErr_SetObject(PyExc_AttributeError, _PyUnicode_FromId(attrid));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -6864,12 +6864,12 @@ slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value)
|
|||
}
|
||||
|
||||
static _Py_Identifier name_op[] = {
|
||||
{0, "__lt__", 0},
|
||||
{0, "__le__", 0},
|
||||
{0, "__eq__", 0},
|
||||
{0, "__ne__", 0},
|
||||
{0, "__gt__", 0},
|
||||
{0, "__ge__", 0}
|
||||
_Py_static_string_init("__lt__"),
|
||||
_Py_static_string_init("__le__"),
|
||||
_Py_static_string_init("__eq__"),
|
||||
_Py_static_string_init("__ne__"),
|
||||
_Py_static_string_init("__gt__"),
|
||||
_Py_static_string_init("__ge__"),
|
||||
};
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue