[Python-checkins] cpython: Issue #15610: The PyImport_ImportModuleEx macro now calls
brett.cannon
python-checkins at python.org
Sat Aug 11 00:55:16 CEST 2012
http://hg.python.org/cpython/rev/9804aec74d4a
changeset: 78490:9804aec74d4a
user: Brett Cannon <brett at python.org>
date: Fri Aug 10 18:55:08 2012 -0400
summary:
Issue #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.
files:
Doc/c-api/import.rst | 6 ++++--
Doc/whatsnew/3.3.rst | 5 +++++
Include/import.h | 2 +-
Misc/NEWS | 3 +++
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst
--- a/Doc/c-api/import.rst
+++ b/Doc/c-api/import.rst
@@ -44,8 +44,7 @@
.. index:: builtin: __import__
Import a module. This is best described by referring to the built-in Python
- function :func:`__import__`, as the standard :func:`__import__` function calls
- this function directly.
+ function :func:`__import__`.
The return value is a new reference to the imported module or top-level
package, or *NULL* with an exception set on failure. Like for
@@ -76,6 +75,9 @@
Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is an
UTF-8 encoded string instead of a Unicode object.
+ .. versionchanged:: 3.3
+ Negative values for **level** are no longer accepted.
+
.. c:function:: PyObject* PyImport_Import(PyObject *name)
This is a higher-level interface that calls the current "import hook
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -1880,6 +1880,11 @@
* :c:func:`PyImport_GetMagicNumber` now returns -1 upon failure.
+* As a negative value for the **level** argument to :func:`__import__` is no
+ longer valid, the same now holds for :c:func:`PyImport_ImportModuleLevel`.
+ This also means that the value of **level** used by
+ :c:func:`PyImport_ImportModuleEx` is now 0 instead of -1.
+
Building C extensions
---------------------
diff --git a/Include/import.h b/Include/import.h
--- a/Include/import.h
+++ b/Include/import.h
@@ -62,7 +62,7 @@
);
#define PyImport_ImportModuleEx(n, g, l, f) \
- PyImport_ImportModuleLevel(n, g, l, f, -1)
+ PyImport_ImportModuleLevel(n, g, l, f, 0)
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -237,6 +237,9 @@
C API
-----
+- Issue #15610: PyImport_ImportModuleEx() now uses a 'level' of 0 instead of
+ -1.
+
- Issues #15169, #14599: Strip out the C implementation of
imp.source_from_cache() used by PyImport_ExecCodeModuleWithPathnames() and
used the Python code instead. Leads to PyImport_ExecCodeModuleObject() to not
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list