diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-07-18 20:59:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-18 20:59:53 (GMT) |
commit | a293fa5915c21b21f5cb8ed9649fbdb37b4c1421 (patch) | |
tree | 4d7ca05e79dad8e2e21024896fb7e5c17624e70b /PC | |
parent | 40f3f11a773b854c6d94746aa3b1881c8ac71b0f (diff) | |
download | cpython-a293fa5915c21b21f5cb8ed9649fbdb37b4c1421.zip cpython-a293fa5915c21b21f5cb8ed9649fbdb37b4c1421.tar.gz cpython-a293fa5915c21b21f5cb8ed9649fbdb37b4c1421.tar.bz2 |
gh-86493: Use PyModule_Add() instead of PyModule_AddObjectRef() (GH-106860)
Diffstat (limited to 'PC')
-rw-r--r-- | PC/msvcrtmodule.c | 17 | ||||
-rw-r--r-- | PC/winreg.c | 10 |
2 files changed, 5 insertions, 22 deletions
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index 53ef26b..afc810a 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -565,15 +565,9 @@ static struct PyMethodDef msvcrt_functions[] = { }; static int -insertptr(PyObject *mod, char *name, void *value) +insertptr(PyObject *mod, const char *name, void *value) { - PyObject *v = PyLong_FromVoidPtr(value); - if (v == NULL) { - return -1; - } - int rc = PyModule_AddObjectRef(mod, name, v); - Py_DECREF(v); - return rc; + return PyModule_Add(mod, name, PyLong_FromVoidPtr(value)); } #define INSERTINT(MOD, NAME, VAL) do { \ @@ -646,12 +640,7 @@ exec_module(PyObject* m) _VC_CRT_MINOR_VERSION, _VC_CRT_BUILD_VERSION, _VC_CRT_RBUILD_VERSION); - if (version == NULL) { - return -1; - } - int st = PyModule_AddObjectRef(m, "CRT_ASSEMBLY_VERSION", version); - Py_DECREF(version); - if (st < 0) { + if (PyModule_Add(m, "CRT_ASSEMBLY_VERSION", version) < 0) { return -1; } #endif diff --git a/PC/winreg.c b/PC/winreg.c index aa2055c..5252f78 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -2079,15 +2079,9 @@ static struct PyMethodDef winreg_methods[] = { } while (0) static int -inskey(PyObject *mod, char *name, HKEY key) +inskey(PyObject *mod, const char *name, HKEY key) { - PyObject *v = PyLong_FromVoidPtr(key); - if (v == NULL) { - return -1; - } - int rc = PyModule_AddObjectRef(mod, name, v); - Py_DECREF(v); - return rc; + return PyModule_Add(mod, name, PyLong_FromVoidPtr(key)); } #define ADD_KEY(VAL) do { \ |