8000 Doh · python/cpython@2c298f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c298f2

Browse files
Doh
1 parent 25a07f8 commit 2c298f2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

PC/winreg.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,16 +2059,11 @@ static struct PyMethodDef winreg_methods[] = {
20592059
NULL,
20602060
};
20612061

2062-
static void
2063-
insint(PyObject * d, char * name, long value)
2064-
{
2065-
PyObject *v = PyLong_FromLong(value);
2066-
if (!v || PyDict_SetItemString(d, name, v))
2067-
PyErr_Clear();
2068-
Py_XDECREF(v);
2069-
}
2070-
2071-
#define ADD_INT(val) insint(d, #val, val)
2062+
#define ADD_INT(VAL) do { \
2063+
if (PyModule_AddIntConstant(m, #VAL, VAL) < 0) { \
2064+
goto error; \
2065+
} \
2066+
} while (0)
20722067

20732068
static int
20742069
inskey(PyObject *mod, char *name, HKEY key)
@@ -2077,7 +2072,7 @@ inskey(PyObject *mod, char *name, HKEY key)
20772072
if (v == NULL) {
20782073
return -1;
20792074
}
2080-
int rc = PyModule_AddObjectRef(name, v);
2075+
int rc = PyModule_AddObjectRef(mod, name, v);
20812076
Py_DECREF(v);
20822077
return rc;
20832078
}
@@ -2177,6 +2172,9 @@ PyMODINIT_FUNC PyInit_winreg(void)
21772172
ADD_INT(REG_RESOURCE_LIST);
21782173
ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR);
21792174
ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST);
2175+
2176 5397 +
#undef ADD_INT
2177+
21802178
return m;
21812179

21822180
error:

0 commit comments

Comments
 (0)
0