Issue #15610: The PyImport_ImportModuleEx macro now calls · pythoncapi/cpython@522267e · GitHub
Skip to content

Commit 522267e

Browse files
committed
Issue python#15610: The PyImport_ImportModuleEx macro now calls
PyImport_ImportModuleLevel() with a 'level' of 0 instead of -1 as the latter is no longer a valid value. Also added a versionchanged note for PyImport_ImportModuleLevel() just in case people don't make the connection between changes to __import__() and this C function.
1 parent f410ce8 commit 522267e

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

Doc/c-api/import.rst

Lines changed: 4 additions & 2 deletions

Doc/whatsnew/3.3.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,11 @@ Porting C code
18801880

18811881
* :c:func:`PyImport_GetMagicNumber` now returns -1 upon failure.
18821882

1883+
* As a negative value for the **level** argument to :func:`__import__` is no
1884+
longer valid, the same now holds for :c:func:`PyImport_ImportModuleLevel`.
1885+
This also means that the value of **level** used by
1886+
:c:func:`PyImport_ImportModuleEx` is now 0 instead of -1.
1887+
18831888

18841889
Building C extensions
18851890
---------------------

Include/import.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
6262
);
6363

6464
#define PyImport_ImportModuleEx(n, g, l, f) \
65-
PyImport_ImportModuleLevel(n, g, l, f, -1)
65+
PyImport_ImportModuleLevel(n, g, l, f, 0)
6666

6767
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
6868
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);

Misc/NEWS

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)