summaryrefslogtreecommitdiffstats
path: root/Objects/moduleobject.c
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-01-30 23:20:25 (GMT)
committerGitHub <noreply@github.com>2020-01-30 23:20:25 (GMT)
commit46874c26ee1fc752e2e6930efa1d223b2351edb8 (patch)
treeb4c85470214ac73ec6e4fa9981bb1f0e7b46472e /Objects/moduleobject.c
parentc232c9110cfefa0935cbf158e35e91746a8a9361 (diff)
downloadcpython-46874c26ee1fc752e2e6930efa1d223b2351edb8.zip
cpython-46874c26ee1fc752e2e6930efa1d223b2351edb8.tar.gz
cpython-46874c26ee1fc752e2e6930efa1d223b2351edb8.tar.bz2
bpo-39487: Merge duplicated _Py_IDENTIFIER identifiers in C code (GH-18254)
Moving repetitive `_Py_IDENTIFIER` instances to a global location helps identify them more easily in regards to sub-interpreter support.
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r--Objects/moduleobject.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 912c258..49cfd57 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -7,6 +7,10 @@
static Py_ssize_t max_module_number;
+_Py_IDENTIFIER(__doc__);
+_Py_IDENTIFIER(__name__);
+_Py_IDENTIFIER(__spec__);
+
typedef struct {
PyObject_HEAD
PyObject *md_dict;
@@ -58,11 +62,8 @@ static int
module_init_dict(PyModuleObject *mod, PyObject *md_dict,
PyObject *name, PyObject *doc)
{
- _Py_IDENTIFIER(__name__);
- _Py_IDENTIFIER(__doc__);
_Py_IDENTIFIER(__package__);
_Py_IDENTIFIER(__loader__);
- _Py_IDENTIFIER(__spec__);
if (md_dict == NULL)
return -1;
@@ -461,7 +462,6 @@ int
PyModule_SetDocString(PyObject *m, const char *doc)
{
PyObject *v;
- _Py_IDENTIFIER(__doc__);
v = PyUnicode_FromString(doc);
if (v == NULL || _PyObject_SetAttrId(m, &PyId___doc__, v) != 0) {
@@ -488,7 +488,6 @@ PyModule_GetDict(PyObject *m)
PyObject*
PyModule_GetNameObject(PyObject *m)
{
- _Py_IDENTIFIER(__name__);
PyObject *d;
PyObject *name;
if (!PyModule_Check(m)) {
@@ -741,10 +740,8 @@ module_getattro(PyModuleObject *m, PyObject *name)
if (getattr) {
return _PyObject_CallOneArg(getattr, name);
}
- _Py_IDENTIFIER(__name__);
mod_name = _PyDict_GetItemId(m->md_dict, &PyId___name__);
if (mod_name && PyUnicode_Check(mod_name)) {
- _Py_IDENTIFIER(__spec__);
Py_INCREF(mod_name);
PyObject *spec = _PyDict_GetItemId(m->md_dict, &PyId___spec__);
Py_XINCREF(spec);