Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use _Py_ID() in classobject.c.
  • Loading branch information
ericsnowcurrently committed Feb 16, 2022
commit 2c2f9172de61e926f9c253aae53479965b750bcd
17 changes: 3 additions & 14 deletions Objects/classobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,7 @@ static PyMemberDef method_memberlist[] = {
static PyObject *
method_get_doc(PyMethodObject *im, void *context)
{
static PyObject *docstr;
if (docstr == NULL) {
docstr= PyUnicode_InternFromString("__doc__");
if (docstr == NULL)
return NULL;
}
return PyObject_GetAttr(im->im_func, docstr);
return PyObject_GetAttr(im->im_func, &_Py_ID(__doc__));
}

static PyGetSetDef method_getset[] = {
Expand Down Expand Up @@ -405,13 +399,8 @@ static PyMemberDef instancemethod_memberlist[] = {
static PyObject *
instancemethod_get_doc(PyObject *self, void *context)
{
static PyObject *docstr;
if (docstr == NULL) {
docstr = PyUnicode_InternFromString("__doc__");
if (docstr == NULL)
return NULL;
}
return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), docstr);
return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self),
&_Py_ID(__doc__));
}

static PyGetSetDef instancemethod_getset[] = {
Expand Down
2 changes: 0 additions & 2 deletions Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ Objects/sliceobject.c - _Py_EllipsisObject -
# cached - initialized once

# manually cached PyUnicodeObject
Objects/classobject.c method_get_doc docstr -
Objects/classobject.c instancemethod_get_doc docstr -
Objects/codeobject.c PyCode_NewEmpty emptystring -
Objects/exceptions.c _check_for_legacy_statements print_prefix -
Objects/exceptions.c _check_for_legacy_statements exec_prefix -
Expand Down