mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-45855: Replaced deprecated PyImport_ImportModuleNoBlock
with PyImport_ImportModule (GH-30046)
This commit is contained in:
parent
e6fe10d340
commit
41026c3155
12 changed files with 17 additions and 16 deletions
|
@ -0,0 +1 @@
|
||||||
|
Replaced deprecated usage of :c:func:`PyImport_ImportModuleNoBlock` with :c:func:`PyImport_ImportModule` in stdlib modules. Patch by Kumar Aditya.
|
|
@ -490,7 +490,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
context = PyUnicode_InternFromString("_ctypes.DllGetClassObject");
|
context = PyUnicode_InternFromString("_ctypes.DllGetClassObject");
|
||||||
|
|
||||||
mod = PyImport_ImportModuleNoBlock("ctypes");
|
mod = PyImport_ImportModule("ctypes");
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
PyErr_WriteUnraisable(context ? context : Py_None);
|
PyErr_WriteUnraisable(context ? context : Py_None);
|
||||||
/* There has been a warning before about this already */
|
/* There has been a warning before about this already */
|
||||||
|
@ -563,7 +563,7 @@ long Call_CanUnloadNow(void)
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
context = PyUnicode_InternFromString("_ctypes.DllCanUnloadNow");
|
context = PyUnicode_InternFromString("_ctypes.DllCanUnloadNow");
|
||||||
|
|
||||||
mod = PyImport_ImportModuleNoBlock("ctypes");
|
mod = PyImport_ImportModule("ctypes");
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
/* OutputDebugString("Could not import ctypes"); */
|
/* OutputDebugString("Could not import ctypes"); */
|
||||||
/* We assume that this error can only occur when shutting
|
/* We assume that this error can only occur when shutting
|
||||||
|
|
|
@ -3959,7 +3959,7 @@ static int
|
||||||
update_lines_cols(void)
|
update_lines_cols(void)
|
||||||
{
|
{
|
||||||
PyObject *o;
|
PyObject *o;
|
||||||
PyObject *m = PyImport_ImportModuleNoBlock("curses");
|
PyObject *m = PyImport_ImportModule("curses");
|
||||||
_Py_IDENTIFIER(LINES);
|
_Py_IDENTIFIER(LINES);
|
||||||
_Py_IDENTIFIER(COLS);
|
_Py_IDENTIFIER(COLS);
|
||||||
|
|
||||||
|
|
|
@ -1625,7 +1625,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
|
||||||
goto Done;
|
goto Done;
|
||||||
{
|
{
|
||||||
PyObject *format;
|
PyObject *format;
|
||||||
PyObject *time = PyImport_ImportModuleNoBlock("time");
|
PyObject *time = PyImport_ImportModule("time");
|
||||||
|
|
||||||
if (time == NULL)
|
if (time == NULL)
|
||||||
goto Done;
|
goto Done;
|
||||||
|
@ -1655,7 +1655,7 @@ static PyObject *
|
||||||
time_time(void)
|
time_time(void)
|
||||||
{
|
{
|
||||||
PyObject *result = NULL;
|
PyObject *result = NULL;
|
||||||
PyObject *time = PyImport_ImportModuleNoBlock("time");
|
PyObject *time = PyImport_ImportModule("time");
|
||||||
|
|
||||||
if (time != NULL) {
|
if (time != NULL) {
|
||||||
_Py_IDENTIFIER(time);
|
_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;
|
PyObject *args;
|
||||||
|
|
||||||
|
|
||||||
time = PyImport_ImportModuleNoBlock("time");
|
time = PyImport_ImportModule("time");
|
||||||
if (time == NULL) {
|
if (time == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -5161,7 +5161,7 @@ datetime_strptime(PyObject *cls, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
module = PyImport_ImportModuleNoBlock("_strptime");
|
module = PyImport_ImportModule("_strptime");
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8219,7 +8219,7 @@ wait_helper(PyObject *module, pid_t pid, int status, struct rusage *ru)
|
||||||
memset(ru, 0, sizeof(*ru));
|
memset(ru, 0, sizeof(*ru));
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *m = PyImport_ImportModuleNoBlock("resource");
|
PyObject *m = PyImport_ImportModule("resource");
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
struct_rusage = PyObject_GetAttr(m, get_posix_state(module)->struct_rusage);
|
struct_rusage = PyObject_GetAttr(m, get_posix_state(module)->struct_rusage);
|
||||||
|
|
|
@ -765,7 +765,7 @@ signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
is_socket = 0;
|
is_socket = 0;
|
||||||
if (sockfd != INVALID_FD) {
|
if (sockfd != INVALID_FD) {
|
||||||
/* Import the _socket module to call WSAStartup() */
|
/* Import the _socket module to call WSAStartup() */
|
||||||
mod = PyImport_ImportModuleNoBlock("_socket");
|
mod = PyImport_ImportModule("_socket");
|
||||||
if (mod == NULL)
|
if (mod == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_DECREF(mod);
|
Py_DECREF(mod);
|
||||||
|
|
|
@ -895,7 +895,7 @@ time_strptime(PyObject *self, PyObject *args)
|
||||||
PyObject *module, *func, *result;
|
PyObject *module, *func, *result;
|
||||||
_Py_IDENTIFIER(_strptime_time);
|
_Py_IDENTIFIER(_strptime_time);
|
||||||
|
|
||||||
module = PyImport_ImportModuleNoBlock("_strptime");
|
module = PyImport_ImportModule("_strptime");
|
||||||
if (!module)
|
if (!module)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1075,7 +1075,7 @@ time_tzset(PyObject *self, PyObject *unused)
|
||||||
{
|
{
|
||||||
PyObject* m;
|
PyObject* m;
|
||||||
|
|
||||||
m = PyImport_ImportModuleNoBlock("time");
|
m = PyImport_ImportModule("time");
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ PyCapsule_Import(const char *name, int no_block)
|
||||||
|
|
||||||
if (object == NULL) {
|
if (object == NULL) {
|
||||||
if (no_block) {
|
if (no_block) {
|
||||||
object = PyImport_ImportModuleNoBlock(trace);
|
object = PyImport_ImportModule(trace);
|
||||||
} else {
|
} else {
|
||||||
object = PyImport_ImportModule(trace);
|
object = PyImport_ImportModule(trace);
|
||||||
if (!object) {
|
if (!object) {
|
||||||
|
|
|
@ -88,7 +88,7 @@ init_normalization(Parser *p)
|
||||||
if (p->normalize) {
|
if (p->normalize) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
PyObject *m = PyImport_ImportModuleNoBlock("unicodedata");
|
PyObject *m = PyImport_ImportModule("unicodedata");
|
||||||
if (!m)
|
if (!m)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -461,7 +461,7 @@ fp_setreadl(struct tok_state *tok, const char* enc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
io = PyImport_ImportModuleNoBlock("io");
|
io = PyImport_ImportModule("io");
|
||||||
if (io == NULL)
|
if (io == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ static int _PyCodecRegistry_Init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = PyImport_ImportModuleNoBlock("encodings");
|
mod = PyImport_ImportModule("encodings");
|
||||||
if (mod == NULL) {
|
if (mod == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
if (io == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
binary = _PyObject_CallMethodId(io, &PyId_open, "Os", filename, "rb");
|
binary = _PyObject_CallMethodId(io, &PyId_open, "Os", filename, "rb");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue