]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.8] bpo-40417: Fix deprecation warning in PyImport_ReloadModule (GH-19750) (GH...
authorRobert Rouhani <robert.rouhani@gmail.com>
Wed, 6 May 2020 00:32:14 +0000 (17:32 -0700)
committerGitHub <noreply@github.com>
Wed, 6 May 2020 00:32:14 +0000 (17:32 -0700)
Automerge-Triggered-By: @brettcannon.
(cherry picked from commit f40bd466bf14029e2687e36e965875adf9d4be1a)

Co-authored-by: Robert Rouhani <robert.rouhani@gmail.com>
Misc/NEWS.d/next/Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst [new file with mode: 0644]
Python/import.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst
new file mode 100644 (file)
index 0000000..932e853
--- /dev/null
@@ -0,0 +1 @@
+Fix imp module deprecation warning when PyImport_ReloadModule is called. Patch by Robert Rouhani.
index b4074d1dfc3fab586990d353c638ee4c2cb5e034..b73fe2f93e26c293188f8d56289e1bad47e2683d 100644 (file)
@@ -1908,23 +1908,23 @@ PyImport_ImportModuleLevel(const char *name, PyObject *globals, PyObject *locals
 PyObject *
 PyImport_ReloadModule(PyObject *m)
 {
-    _Py_IDENTIFIER(imp);
+    _Py_IDENTIFIER(importlib);
     _Py_IDENTIFIER(reload);
     PyObject *reloaded_module = NULL;
-    PyObject *imp = _PyImport_GetModuleId(&PyId_imp);
-    if (imp == NULL) {
+    PyObject *importlib = _PyImport_GetModuleId(&PyId_importlib);
+    if (importlib == NULL) {
         if (PyErr_Occurred()) {
             return NULL;
         }
 
-        imp = PyImport_ImportModule("imp");
-        if (imp == NULL) {
+        importlib = PyImport_ImportModule("importlib");
+        if (importlib == NULL) {
             return NULL;
         }
     }
 
-    reloaded_module = _PyObject_CallMethodIdObjArgs(imp, &PyId_reload, m, NULL);
-    Py_DECREF(imp);
+    reloaded_module = _PyObject_CallMethodIdObjArgs(importlib, &PyId_reload, m, NULL);
+    Py_DECREF(importlib);
     return reloaded_module;
 }