]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105396: Deprecate PyImport_ImportModuleNoBlock() function (#105397)
authorVictor Stinner <vstinner@python.org>
Fri, 9 Jun 2023 08:30:57 +0000 (10:30 +0200)
committerGitHub <noreply@github.com>
Fri, 9 Jun 2023 08:30:57 +0000 (10:30 +0200)
Deprecate the PyImport_ImportModuleNoBlock() function which is just
an alias to PyImport_ImportModule() since Python 3.3.

Doc/c-api/import.rst
Doc/whatsnew/3.13.rst
Include/import.h
Misc/NEWS.d/next/C API/2023-06-06-17-43-28.gh-issue-105396.FQJG5B.rst [new file with mode: 0644]
Python/import.c

index 79843ba521ab938337336aa6af58b5327c675257..6db20237f3fdb068b225ab28d3e38f6aa966685f 100644 (file)
@@ -38,6 +38,9 @@ Importing Modules
       to per-module locks for most purposes, so this function's special
       behaviour isn't needed anymore.
 
+   .. deprecated-removed:: 3.13 3.15
+      Use :c:func:`PyImport_ImportModule` instead.
+
 
 .. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
 
index 502cafdaf5e19f95a5c2366e478fcdcd8f56174c..4849ed72020c7af6efd125fd4f8ca2bf891bd474 100644 (file)
@@ -407,6 +407,11 @@ Deprecated
 
   (Contributed by Victor Stinner in :gh:`105145`.)
 
+* Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function which is just
+  an alias to :c:func:`PyImport_ImportModule` since Python 3.3.
+  Scheduled for removal in Python 3.15.
+  (Contributed by Victor Stinner in :gh:`105396`.)
+
 Removed
 -------
 
index 5d5f3425b8e715e4cdc718e479d669e605acf6d7..6c63744edb063437f94658dea02cf04578e73603 100644 (file)
@@ -46,7 +46,7 @@ PyAPI_FUNC(PyObject *) PyImport_AddModule(
 PyAPI_FUNC(PyObject *) PyImport_ImportModule(
     const char *name            /* UTF-8 encoded string */
     );
-PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
+Py_DEPRECATED(3.13) PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
     const char *name            /* UTF-8 encoded string */
     );
 PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
diff --git a/Misc/NEWS.d/next/C API/2023-06-06-17-43-28.gh-issue-105396.FQJG5B.rst b/Misc/NEWS.d/next/C API/2023-06-06-17-43-28.gh-issue-105396.FQJG5B.rst
new file mode 100644 (file)
index 0000000..cf82f62
--- /dev/null
@@ -0,0 +1,3 @@
+Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function which is just
+an alias to :c:func:`PyImport_ImportModule` since Python 3.3. Patch by
+Victor Stinner.
index 7f04b1aa609f8aacaf6572941854948f8eaffc48..71cce8e4f623dd0a9da3737b3add14074929708d 100644 (file)
@@ -2439,6 +2439,12 @@ PyImport_ImportModule(const char *name)
 PyObject *
 PyImport_ImportModuleNoBlock(const char *name)
 {
+    if (PyErr_WarnEx(PyExc_DeprecationWarning,
+        "PyImport_ImportModuleNoBlock() is deprecated and scheduled for "
+        "removal in Python 3.15. Use PyImport_ImportModule() instead.", 1))
+    {
+        return NULL;
+    }
     return PyImport_ImportModule(name);
 }