diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2021-12-12 08:45:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-12 08:45:20 (GMT) |
commit | 41026c3155012d6ea50e01205c163b6739c675b8 (patch) | |
tree | efcb12a3838254362917553af0b6cfb230e2e7d1 | |
parent | e6fe10d34096a23be7d26271cf6aba429313b01d (diff) | |
download | cpython-41026c3155012d6ea50e01205c163b6739c675b8.zip cpython-41026c3155012d6ea50e01205c163b6739c675b8.tar.gz cpython-41026c3155012d6ea50e01205c163b6739c675b8.tar.bz2 |
bpo-45855: Replaced deprecated `PyImport_ImportModuleNoBlock` with PyImport_ImportModule (GH-30046)
-rw-r--r-- | Misc/NEWS.d/next/C API/2021-12-11-08-41-36.bpo-45855.Lq2_gR.rst | 1 | ||||
-rw-r--r-- | Modules/_ctypes/callbacks.c | 4 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 2 | ||||
-rw-r--r-- | Modules/_datetimemodule.c | 8 | ||||
-rw-r--r-- | Modules/posixmodule.c | 2 | ||||
-rw-r--r-- | Modules/signalmodule.c | 2 | ||||
-rw-r--r-- | Modules/timemodule.c | 4 | ||||
-rw-r--r-- | Objects/capsule.c | 2 | ||||
-rw-r--r-- | Parser/pegen.c | 2 | ||||
-rw-r--r-- | Parser/tokenizer.c | 2 | ||||
-rw-r--r-- | Python/codecs.c | 2 | ||||
-rw-r--r-- | Python/traceback.c | 2 |
12 files changed, 17 insertions, 16 deletions
diff --git a/Misc/NEWS.d/next/C API/2021-12-11-08-41-36.bpo-45855.Lq2_gR.rst b/Misc/NEWS.d/next/C API/2021-12-11-08-41-36.bpo-45855.Lq2_gR.rst new file mode 100644 index 0000000..03258df --- /dev/null +++ b/Misc/NEWS.d/next/C API/2021-12-11-08-41-36.bpo-45855.Lq2_gR.rst @@ -0,0 +1 @@ +Replaced deprecated usage of :c:func:`PyImport_ImportModuleNoBlock` with :c:func:`PyImport_ImportModule` in stdlib modules. Patch by Kumar Aditya.
\ No newline at end of file diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 0f7789a..01d7037 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -490,7 +490,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) if (context == NULL) context = PyUnicode_InternFromString("_ctypes.DllGetClassObject"); - mod = PyImport_ImportModuleNoBlock("ctypes"); + mod = PyImport_ImportModule("ctypes"); if (!mod) { PyErr_WriteUnraisable(context ? context : Py_None); /* There has been a warning before about this already */ @@ -563,7 +563,7 @@ long Call_CanUnloadNow(void) if (context == NULL) context = PyUnicode_InternFromString("_ctypes.DllCanUnloadNow"); - mod = PyImport_ImportModuleNoBlock("ctypes"); + mod = PyImport_ImportModule("ctypes"); if (!mod) { /* OutputDebugString("Could not import ctypes"); */ /* We assume that this error can only occur when shutting diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 7ebad69..bf742da 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -3959,7 +3959,7 @@ static int update_lines_cols(void) { PyObject *o; - PyObject *m = PyImport_ImportModuleNoBlock("curses"); + PyObject *m = PyImport_ImportModule("curses"); _Py_IDENTIFIER(LINES); _Py_IDENTIFIER(COLS); diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 67441eb..fda8401 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1625,7 +1625,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, goto Done; { PyObject *format; - PyObject *time = PyImport_ImportModuleNoBlock("time"); + PyObject *time = PyImport_ImportModule("time"); if (time == NULL) goto Done; @@ -1655,7 +1655,7 @@ static PyObject * time_time(void) { PyObject *result = NULL; - PyObject *time = PyImport_ImportModuleNoBlock("time"); + PyObject *time = PyImport_ImportModule("time"); if (time != NULL) { _Py_IDENTIFIER(time); @@ -1678,7 +1678,7 @@ build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag) PyObject *args; - time = PyImport_ImportModuleNoBlock("time"); + time = PyImport_ImportModule("time"); if (time == NULL) { return NULL; } @@ -5161,7 +5161,7 @@ datetime_strptime(PyObject *cls, PyObject *args) return NULL; if (module == NULL) { - module = PyImport_ImportModuleNoBlock("_strptime"); + module = PyImport_ImportModule("_strptime"); if (module == NULL) return NULL; } diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2d95efe..b3a5757 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -8219,7 +8219,7 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru) memset(ru, 0, sizeof(*ru)); } - PyObject *m = PyImport_ImportModuleNoBlock("resource"); + PyObject *m = PyImport_ImportModule("resource"); if (m == NULL) return NULL; struct_rusage = PyObject_GetAttr(m, get_posix_state(module)->struct_rusage); diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index bc891e8..2013f16 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -765,7 +765,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds) is_socket = 0; if (sockfd != INVALID_FD) { /* Import the _socket module to call WSAStartup() */ - mod = PyImport_ImportModuleNoBlock("_socket"); + mod = PyImport_ImportModule("_socket"); if (mod == NULL) return NULL; Py_DECREF(mod); diff --git a/Modules/timemodule.c b/Modules/timemodule.c index bb71390..dd81d35 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -895,7 +895,7 @@ time_strptime(PyObject *self, PyObject *args) PyObject *module, *func, *result; _Py_IDENTIFIER(_strptime_time); - module = PyImport_ImportModuleNoBlock("_strptime"); + module = PyImport_ImportModule("_strptime"); if (!module) return NULL; @@ -1075,7 +1075,7 @@ time_tzset(PyObject *self, PyObject *unused) { PyObject* m; - m = PyImport_ImportModuleNoBlock("time"); + m = PyImport_ImportModule("time"); if (m == NULL) { return NULL; } diff --git a/Objects/capsule.c b/Objects/capsule.c index 800a6c4..9c9dcf3 100644 --- a/Objects/capsule.c +++ b/Objects/capsule.c @@ -215,7 +215,7 @@ PyCapsule_Import(const char *name, int no_block) if (object == NULL) { if (no_block) { - object = PyImport_ImportModuleNoBlock(trace); + object = PyImport_ImportModule(trace); } else { object = PyImport_ImportModule(trace); if (!object) { diff --git a/Parser/pegen.c b/Parser/pegen.c index 4158a81..870085e 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -88,7 +88,7 @@ init_normalization(Parser *p) if (p->normalize) { return 1; } - PyObject *m = PyImport_ImportModuleNoBlock("unicodedata"); + PyObject *m = PyImport_ImportModule("unicodedata"); if (!m) { return 0; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index a560572..5e35d6f 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -461,7 +461,7 @@ fp_setreadl(struct tok_state *tok, const char* enc) return 0; } - io = PyImport_ImportModuleNoBlock("io"); + io = PyImport_ImportModule("io"); if (io == NULL) return 0; diff --git a/Python/codecs.c b/Python/codecs.c index b7c8db7..343b6e2 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -1527,7 +1527,7 @@ static int _PyCodecRegistry_Init(void) } } - mod = PyImport_ImportModuleNoBlock("encodings"); + mod = PyImport_ImportModule("encodings"); if (mod == NULL) { return -1; } diff --git a/Python/traceback.c b/Python/traceback.c index b0ff5e9..4d6cbaa 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -447,7 +447,7 @@ display_source_line_with_margin(PyObject *f, PyObject *filename, int lineno, int } } - io = PyImport_ImportModuleNoBlock("io"); + io = PyImport_ImportModule("io"); if (io == NULL) return -1; binary = _PyObject_CallMethodId(io, &PyId_open, "Os", filename, "rb"); |