Skip to content

Commit 53e9ec4

Browse files
committed
Issue python#19512: Use the new _PyId_builtins identifier
1 parent ad14ccd commit 53e9ec4

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎Modules/_lsprof.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ normalizeUserObj(PyObject *obj)
185185
}
186186
}
187187
if (modname != NULL) {
188-
if (PyUnicode_CompareWithASCIIString(modname, "builtins") != 0) {
188+
if (_PyUnicode_CompareWithId(modname, &_PyId_builtins) != 0) {
189189
PyObject *result;
190190
result = PyUnicode_FromFormat("<%U.%s>", modname,
191191
fn->m_ml->ml_name);

‎Objects/object.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,12 @@ PyObject_SelfIter(PyObject *obj)
11221122
PyObject *
11231123
_PyObject_GetBuiltin(const char *name)
11241124
{
1125-
PyObject *mod, *attr;
1126-
mod = PyImport_ImportModule("builtins");
1125+
PyObject *mod_name, *mod, *attr;
1126+
1127+
mod_name = _PyUnicode_FromId(&_PyId_builtins); /* borrowed */
1128+
if (mod_name == NULL)
1129+
return NULL;
1130+
mod = PyImport_Import(mod_name);
11271131
if (mod == NULL)
11281132
return NULL;
11291133
attr = PyObject_GetAttrString(mod, name);

‎Python/import.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ PyImport_Cleanup(void)
310310

311311
/* XXX Perhaps these precautions are obsolete. Who knows? */
312312

313-
value = PyDict_GetItemString(modules, "builtins");
313+
value = _PyDict_GetItemId(modules, &_PyId_builtins);
314314
if (value != NULL && PyModule_Check(value)) {
315315
dict = PyModule_GetDict(value);
316316
if (Py_VerboseFlag)

0 commit comments

Comments
 (0)