]> granicus.if.org Git - python/commitdiff
Issue #15610: The PyImport_ImportModuleEx macro now calls
authorBrett Cannon <brett@python.org>
Fri, 10 Aug 2012 22:55:08 +0000 (18:55 -0400)
committerBrett Cannon <brett@python.org>
Fri, 10 Aug 2012 22:55:08 +0000 (18:55 -0400)
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.

Doc/c-api/import.rst
Doc/whatsnew/3.3.rst
Include/import.h
Misc/NEWS

index c7180578dda4450a8e23fd275915383b6c8842b2..c3c8f42cf0191d28718241c20238839d69cad1b8 100644 (file)
@@ -44,8 +44,7 @@ Importing Modules
    .. 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 @@ Importing Modules
    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
index 858fce8de4e670651b67712bef9f1f891bd0e9d4..a64424d324e97af0ddd6c4de715ff0664f2041c7 100644 (file)
@@ -1880,6 +1880,11 @@ Porting C code
 
 * :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
 ---------------------
index bc21ae2f478909cf8934c0a580af14edb3d6e0ff..fdc27336c35ba7834160c620295db4cdfe7ff3f5 100644 (file)
@@ -62,7 +62,7 @@ PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
     );
 
 #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);
index 6abe3cb4f41bc9654c94ec7cfddd74b11d6080b2..972e769c05ae6e5c33820bfbcaf95175b18c270e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -237,6 +237,9 @@ Library
 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