From 30bd7dd535bb038a24c2d191c1b991764213c72c Mon Sep 17 00:00:00 2001 From: Robert Rouhani Date: Tue, 28 Apr 2020 00:15:59 -0700 Subject: [PATCH 1/4] bpo-40417: Fix deprecation warning in PyImport_ReloadModule --- Python/import.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/import.c b/Python/import.c index a8743458dd5c96..7fd8ddef253fbb 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1977,16 +1977,16 @@ 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); + PyObject *imp = _PyImport_GetModuleId(&PyId_importlib); if (imp == NULL) { if (PyErr_Occurred()) { return NULL; } - imp = PyImport_ImportModule("imp"); + imp = PyImport_ImportModule("importlib"); if (imp == NULL) { return NULL; } From aebdb83fbba00a07ca707f497aea868d6fdf3ab6 Mon Sep 17 00:00:00 2001 From: Robert Rouhani Date: Fri, 1 May 2020 10:03:31 -0700 Subject: [PATCH 2/4] Rename variable from imp to importlib to match module name --- Python/import.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Python/import.c b/Python/import.c index 7fd8ddef253fbb..dfaea4531b470d 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1980,20 +1980,20 @@ PyImport_ReloadModule(PyObject *m) _Py_IDENTIFIER(importlib); _Py_IDENTIFIER(reload); PyObject *reloaded_module = NULL; - PyObject *imp = _PyImport_GetModuleId(&PyId_importlib); - if (imp == NULL) { + PyObject *importlib = _PyImport_GetModuleId(&PyId_importlib); + if (importlib == NULL) { if (PyErr_Occurred()) { return NULL; } - imp = PyImport_ImportModule("importlib"); - if (imp == NULL) { + importlib = PyImport_ImportModule("importlib"); + if (importlib == NULL) { return NULL; } } - reloaded_module = _PyObject_CallMethodIdOneArg(imp, &PyId_reload, m); - Py_DECREF(imp); + reloaded_module = _PyObject_CallMethodIdOneArg(importlib, &PyId_reload, m); + Py_DECREF(importlib); return reloaded_module; } From 34d9a6763653068596977f48101fd22f3c7f31fa Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 1 May 2020 19:04:53 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst 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 index 00000000000000..06e71b929766ae --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst @@ -0,0 +1 @@ +Fix "imp" module deprecation warning when PyImport_ReloadModule is called \ No newline at end of file From f02af37ea79ceb41cdd290d169d516c9cc79c6aa Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 1 May 2020 16:07:56 -0700 Subject: [PATCH 4/4] Thank the PR author --- .../Core and Builtins/2020-05-01-19-04-52.bpo-40417.Sti2lJ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 06e71b929766ae..932e853a8933d1 100644 --- 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 @@ -1 +1 @@ -Fix "imp" module deprecation warning when PyImport_ReloadModule is called \ No newline at end of file +Fix imp module deprecation warning when PyImport_ReloadModule is called. Patch by Robert Rouhani.