8000 bpo-1635741: port winapi to multi-stage init by koubaa · Pull Request #21371 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1635741: port winapi to multi-stage init #21371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 13, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix refcount
  • Loading branch information
= authored and koubaa committed Aug 13, 2020
commit 283911c92cf8c72e761347d652d32f852080dee1
14 changes: 13 additions & 1 deletion Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,20 @@ static PyMethodDef winapi_functions[] = {
{NULL, NULL}
};

static int
SetWinAPIConstant(PyObject* d, const char* fmt, const char* constantString, int constant) {
PyObject *value = Py_BuildValue(fmt, constant);
if (PyDict_SetItemString(d, constantString, value) < 0) {
Py_DECREF(value);
return -1;
}

Py_DECREF(value);
return 0;
}

#define WINAPI_CONSTANT(fmt, con) \
if (PyDict_SetItemString(d, #con, Py_BuildValue(fmt, con)) < 0) return -1
if (SetWinAPIConstant(d, fmt, #con, con) < 0) return -1

static int winapi_exec(PyObject *m)
{
Expand Down
0