8000 gh-105396: Deprecate PyImport_ImportModuleNoBlock() function (#105397) · python/cpython@3e525d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e525d2

Browse files
authored
gh-105396: Deprecate PyImport_ImportModuleNoBlock() function (#105397)
Deprecate the PyImport_ImportModuleNoBlock() function which is just an alias to PyImport_ImportModule() since Python 3.3.
1 parent a5f23d4 commit 3e525d2

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

Doc/c-api/import.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Importing Modules
3838
to per-module locks for most purposes, so this function's special
3939
behaviour isn't needed anymore.
4040
41+
.. deprecated-removed:: 3.13 3.15
42+
Use :c:func:`PyImport_ImportModule` instead.
43+
4144
4245
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
4346

Doc/whatsnew/3.13.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ Deprecated
407407

408408
(Contributed by Victor Stinner in :gh:`105145`.)
409409

410+
* Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function which is just
411+
an alias to :c:func:`PyImport_ImportModule` since Python 3.3.
412+
Scheduled for removal in Python 3.15.
413+
(Contributed by Victor Stinner in :gh:`105396`.)
414+
410415
Removed
411416
-------
412417

Include/import.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ PyAPI_FUNC(PyObject *) PyImport_AddModule(
4646
PyAPI_FUNC(PyObject *) PyImport_ImportModule(
4747
const char *name /* UTF-8 encoded string */
4848
);
49-
PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
49+
Py_DEPRECATED(3.13) PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
5050
const char *name /* UTF-8 encoded string */
5151
);
5252
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Deprecate the :c:func:`PyImport_ImportModuleNoBlock` function which is just
2+
an alias to :c:func:`PyImport_ImportModule` since Python 3.3. Patch by
3+
Victor Stinner.

Python/import.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,12 @@ PyImport_ImportModule(const char *name)
24392439
PyObject *
24402440
PyImport_ImportModuleNoBlock(const char *name)
24412441
{
2442+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
2443+
"PyImport_ImportModuleNoBlock() is deprecated and scheduled for "
2444+
"removal in Python 3.15. Use PyImport_ImportModule() instead.", 1))
2445+
{
2446+
return NULL;
2447+
}
24422448
return PyImport_ImportModule(name);
24432449
}
24442450

0 commit comments

Comments
 (0)
0