Issue #19512: Use the new _PyId_builtins identifier · pythoncapi/cpython@53e9ec4 · GitHub
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

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

0 commit comments

Comments
 (0)