diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-07-25 11:34:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 11:34:49 (GMT) |
commit | 329e4a1a3f8c53d9d120d2eed93b95a04b826f2f (patch) | |
tree | 8bbe3eb47cf37493fcd3289d98643605e0217c78 /Modules/binascii.c | |
parent | f443b54a2f14e386a91fe4b09f41a265445008b8 (diff) | |
download | cpython-329e4a1a3f8c53d9d120d2eed93b95a04b826f2f.zip cpython-329e4a1a3f8c53d9d120d2eed93b95a04b826f2f.tar.gz cpython-329e4a1a3f8c53d9d120d2eed93b95a04b826f2f.tar.bz2 |
gh-86493: Modernize modules initialization code (GH-106858)
Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated
PyModule_AddObject().
Diffstat (limited to 'Modules/binascii.c')
-rw-r--r-- | Modules/binascii.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c index cf93287..a87a2ef 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -1253,32 +1253,20 @@ static struct PyMethodDef binascii_module_methods[] = { PyDoc_STRVAR(doc_binascii, "Conversion between binary data and ASCII"); static int -binascii_exec(PyObject *module) { - int result; +binascii_exec(PyObject *module) +{ binascii_state *state = PyModule_GetState(module); if (state == NULL) { return -1; } state->Error = PyErr_NewException("binascii.Error", PyExc_ValueError, NULL); - if (state->Error == NULL) { - return -1; - } - Py_INCREF(state->Error); - result = PyModule_AddObject(module, "Error", state->Error); - if (result == -1) { - Py_DECREF(state->Error); + if (PyModule_AddObjectRef(module, "Error", state->Error) < 0) { return -1; } state->Incomplete = PyErr_NewException("binascii.Incomplete", NULL, NULL); - if (state->Incomplete == NULL) { - return -1; - } - Py_INCREF(state->Incomplete); - result = PyModule_AddObject(module, "Incomplete", state->Incomplete); - if (result == -1) { - Py_DECREF(state->Incomplete); + if (PyModule_AddObjectRef(module, "Incomplete", state->Incomplete) < 0) { return -1; } |