mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-108308: Replace _PyDict_GetItemStringWithError() (#108372)
Replace _PyDict_GetItemStringWithError() calls with PyDict_GetItemStringRef() which returns a strong reference to the item. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
1700d34d31
commit
4dc9f48930
4 changed files with 32 additions and 39 deletions
|
|
@ -1,7 +1,6 @@
|
|||
/* Module definition and import implementation */
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_dict.h" // _PyDict_GetItemStringWithError()
|
||||
#include "pycore_hashtable.h" // _Py_hashtable_new_full()
|
||||
#include "pycore_import.h" // _PyImport_BootstrapImp()
|
||||
#include "pycore_initconfig.h" // _PyStatus_OK()
|
||||
|
|
@ -2435,12 +2434,11 @@ int
|
|||
_PyImport_InitDefaultImportFunc(PyInterpreterState *interp)
|
||||
{
|
||||
// Get the __import__ function
|
||||
PyObject *import_func = _PyDict_GetItemStringWithError(interp->builtins,
|
||||
"__import__");
|
||||
if (import_func == NULL) {
|
||||
PyObject *import_func;
|
||||
if (PyDict_GetItemStringRef(interp->builtins, "__import__", &import_func) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
IMPORT_FUNC(interp) = Py_NewRef(import_func);
|
||||
IMPORT_FUNC(interp) = import_func;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue