mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-108314: Add PyDict_ContainsString() function (#108323)
This commit is contained in:
parent
c163d7f0b6
commit
6726626646
10 changed files with 112 additions and 36 deletions
|
@ -2220,10 +2220,11 @@ add_main_module(PyInterpreterState *interp)
|
|||
}
|
||||
Py_DECREF(ann_dict);
|
||||
|
||||
if (_PyDict_GetItemStringWithError(d, "__builtins__") == NULL) {
|
||||
if (PyErr_Occurred()) {
|
||||
return _PyStatus_ERR("Failed to test __main__.__builtins__");
|
||||
}
|
||||
int has_builtins = PyDict_ContainsString(d, "__builtins__");
|
||||
if (has_builtins < 0) {
|
||||
return _PyStatus_ERR("Failed to test __main__.__builtins__");
|
||||
}
|
||||
if (!has_builtins) {
|
||||
PyObject *bimod = PyImport_ImportModule("builtins");
|
||||
if (bimod == NULL) {
|
||||
return _PyStatus_ERR("Failed to retrieve builtins module");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue