mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +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
|
@ -3163,9 +3163,8 @@ array_modexec(PyObject *m)
|
|||
CREATE_TYPE(m, state->ArrayIterType, &arrayiter_spec);
|
||||
Py_SET_TYPE(state->ArrayIterType, &PyType_Type);
|
||||
|
||||
if (PyModule_AddObject(m, "ArrayType",
|
||||
Py_NewRef((PyObject *)state->ArrayType)) < 0) {
|
||||
Py_DECREF((PyObject *)state->ArrayType);
|
||||
if (PyModule_AddObjectRef(m, "ArrayType",
|
||||
(PyObject *)state->ArrayType) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -3193,8 +3192,7 @@ array_modexec(PyObject *m)
|
|||
*p++ = (char)descr->typecode;
|
||||
}
|
||||
typecodes = PyUnicode_DecodeASCII(buffer, p - buffer, NULL);
|
||||
if (PyModule_AddObject(m, "typecodes", typecodes) < 0) {
|
||||
Py_XDECREF(typecodes);
|
||||
if (PyModule_Add(m, "typecodes", typecodes) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue