mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-86493: Modernize modules initialization code (GH-106858)
Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated PyModule_AddObject().
This commit is contained in:
parent
f443b54a2f
commit
329e4a1a3f
29 changed files with 84 additions and 292 deletions
|
@ -372,9 +372,7 @@ resource_exec(PyObject *module)
|
|||
} while (0)
|
||||
|
||||
/* Add some symbolic constants to the module */
|
||||
Py_INCREF(PyExc_OSError);
|
||||
if (PyModule_AddObject(module, "error", PyExc_OSError) < 0) {
|
||||
Py_DECREF(PyExc_OSError);
|
||||
if (PyModule_AddObjectRef(module, "error", PyExc_OSError) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -502,12 +500,7 @@ resource_exec(PyObject *module)
|
|||
{
|
||||
v = PyLong_FromLong((long) RLIM_INFINITY);
|
||||
}
|
||||
if (!v) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyModule_AddObject(module, "RLIM_INFINITY", v) < 0) {
|
||||
Py_DECREF(v);
|
||||
if (PyModule_Add(module, "RLIM_INFINITY", v) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue