Skip to content

Commit 41026c3

Browse files
bpo-45855: Replaced deprecated PyImport_ImportModuleNoBlock with PyImport_ImportModule (pythonGH-30046)
1 parent e6fe10d commit 41026c3

File tree

12 files changed

+17
-16
lines changed

12 files changed

+17
-16
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replaced deprecated usage of :c:func:`PyImport_ImportModuleNoBlock` with :c:func:`PyImport_ImportModule` in stdlib modules. Patch by Kumar Aditya.

Modules/_ctypes/callbacks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
490490
if (context == NULL)
491491
context = PyUnicode_InternFromString("_ctypes.DllGetClassObject");
492492

493-
mod = PyImport_ImportModuleNoBlock("ctypes");
493+
mod = PyImport_ImportModule("ctypes");
494494
if (!mod) {
495495
PyErr_WriteUnraisable(context ? context : Py_None);
496496
/* There has been a warning before about this already */
@@ -563,7 +563,7 @@ long Call_CanUnloadNow(void)
563563
if (context == NULL)
564564
context = PyUnicode_InternFromString("_ctypes.DllCanUnloadNow");
565565

566-
mod = PyImport_ImportModuleNoBlock("ctypes");
566+
mod = PyImport_ImportModule("ctypes");
567567
if (!mod) {
568568
/* OutputDebugString("Could not import ctypes"); */
569569
/* We assume that this error can only occur when shutting

Modules/_cursesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3959,7 +3959,7 @@ static int
39593959
update_lines_cols(void)
39603960
{
39613961
PyObject *o;
3962-
PyObject *m = PyImport_ImportModuleNoBlock("curses");
3962+
PyObject *m = PyImport_ImportModule("curses");
39633963
_Py_IDENTIFIER(LINES);
39643964
_Py_IDENTIFIER(COLS);
39653965

Modules/_datetimemodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
16251625
goto Done;
16261626
{
16271627
PyObject *format;
1628-
PyObject *time = PyImport_ImportModuleNoBlock("time");
1628+
PyObject *time = PyImport_ImportModule("time");
16291629

16301630
if (time == NULL)
16311631
goto Done;
@@ -1655,7 +1655,7 @@ static PyObject *
16551655
time_time(void)
16561656
{
16571657
PyObject *result = NULL;
1658-
PyObject *time = PyImport_ImportModuleNoBlock("time");
1658+
PyObject *time = PyImport_ImportModule("time");
16591659

16601660
if (time != NULL) {
16611661
_Py_IDENTIFIER(time);
@@ -1678,7 +1678,7 @@ build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag)
16781678
PyObject *args;
16791679

16801680

1681-
time = PyImport_ImportModuleNoBlock("time");
1681+
time = PyImport_ImportModule("time");
16821682
if (time == NULL) {
16831683
return NULL;
16841684
}
@@ -5161,7 +5161,7 @@ datetime_strptime(PyObject *cls, PyObject *args)
51615161
return NULL;
51625162

51635163
if (module == NULL) {
5164-
module = PyImport_ImportModuleNoBlock("_strptime");
5164+
module = PyImport_ImportModule("_strptime");
51655165
if (module == NULL)
51665166
return NULL;
51675167
}

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8219,7 +8219,7 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru)
82198219
memset(ru, 0, sizeof(*ru));
82208220
}
82218221

8222-
PyObject *m = PyImport_ImportModuleNoBlock("resource");
8222+
PyObject *m = PyImport_ImportModule("resource");
82238223
if (m == NULL)
82248224
return NULL;
82258225
struct_rusage = PyObject_GetAttr(m, get_posix_state(module)->struct_rusage);

Modules/signalmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds)
765765
is_socket = 0;
766766
if (sockfd != INVALID_FD) {
767767
/* Import the _socket module to call WSAStartup() */
768-
mod = PyImport_ImportModuleNoBlock("_socket");
768+
mod = PyImport_ImportModule("_socket");
769769
if (mod == NULL)
770770
return NULL;
771771
Py_DECREF(mod);

Modules/timemodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ time_strptime(PyObject *self, PyObject *args)
895895
PyObject *module, *func, *result;
896896
_Py_IDENTIFIER(_strptime_time);
897897

898-
module = PyImport_ImportModuleNoBlock("_strptime");
898+
module = PyImport_ImportModule("_strptime");
899899
if (!module)
900900
return NULL;
901901

@@ -1075,7 +1075,7 @@ time_tzset(PyObject *self, PyObject *unused)
10751075
{
10761076
PyObject* m;
10771077

1078-
m = PyImport_ImportModuleNoBlock("time");
1078+
m = PyImport_ImportModule("time");
10791079
if (m == NULL) {
10801080
return NULL;
10811081
}

Objects/capsule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ PyCapsule_Import(const char *name, int no_block)
215215

216216
if (object == NULL) {
217217
if (no_block) {
218-
object = PyImport_ImportModuleNoBlock(trace);
218+
object = PyImport_ImportModule(trace);
219219
} else {
220220
object = PyImport_ImportModule(trace);
221221
if (!object) {

Parser/pegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ init_normalization(Parser *p)
8888
if (p->normalize) {
8989
return 1;
9090
}
91-
PyObject *m = PyImport_ImportModuleNoBlock("unicodedata");
91+
PyObject *m = PyImport_ImportModule("unicodedata");
9292
if (!m)
9393
{
9494
return 0;

Parser/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ fp_setreadl(struct tok_state *tok, const char* enc)
461461
return 0;
462462
}
463463

464-
io = PyImport_ImportModuleNoBlock("io");
464+
io = PyImport_ImportModule("io");
465465
if (io == NULL)
466466
return 0;
467467

0 commit comments

Comments
 (0)