diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-02-23 00:23:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 00:23:51 (GMT) |
commit | 1f455361ecfb1892e375bdbee813cdf095b6cfb8 (patch) | |
tree | d7def4d5d167965a45c4b0e30bb5a1a0bb5c3b4a /Objects/classobject.c | |
parent | cff4d5c5d29528299ec1ac5b3b3a6f7735577c01 (diff) | |
download | cpython-1f455361ecfb1892e375bdbee813cdf095b6cfb8.zip cpython-1f455361ecfb1892e375bdbee813cdf095b6cfb8.tar.gz cpython-1f455361ecfb1892e375bdbee813cdf095b6cfb8.tar.bz2 |
bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)
https://bugs.python.org/issue46765
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index d7ccf31..3b1c253 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -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[] = { @@ -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[] = { |