summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-20 06:48:14 (GMT)
committerGitHub <noreply@github.com>2023-06-20 06:48:14 (GMT)
commit03f1a132eeb34c738812161947ef171b21d58c25 (patch)
treeefb632b4c885e58425bfd563c92137ef60f7d72d /Python/pythonrun.c
parent7f97c8e367869e2aebe9f28bc5f8d4ce36448878 (diff)
downloadcpython-03f1a132eeb34c738812161947ef171b21d58c25.zip
cpython-03f1a132eeb34c738812161947ef171b21d58c25.tar.gz
cpython-03f1a132eeb34c738812161947ef171b21d58c25.tar.bz2
gh-105922: Add PyImport_AddModuleRef() function (#105923)
* Add tests on PyImport_AddModuleRef(), PyImport_AddModule() and PyImport_AddModuleObject(). * pythonrun.c: Replace Py_XNewRef(PyImport_AddModule(name)) with PyImport_AddModuleRef(name).
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f9e798e..af82fa4 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -406,7 +406,7 @@ _PyRun_SimpleFileObject(FILE *fp, PyObject *filename, int closeit,
{
int ret = -1;
- PyObject *main_module = Py_XNewRef(PyImport_AddModule("__main__"));
+ PyObject *main_module = PyImport_AddModuleRef("__main__");
if (main_module == NULL)
return -1;
PyObject *dict = PyModule_GetDict(main_module); // borrowed ref
@@ -502,7 +502,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
int
PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
{
- PyObject *main_module = Py_XNewRef(PyImport_AddModule("__main__"));
+ PyObject *main_module = PyImport_AddModuleRef("__main__");
if (main_module == NULL) {
return -1;
}