Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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
update based on review
  • Loading branch information
koubaa committed Aug 13, 2020
commit e0e1b30cf0812876d7ebba93de3468fe3b99c6b5
21 changes: 8 additions & 13 deletions 21 Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1910,21 +1910,15 @@ 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) { \
PyObject *value = Py_BuildValue(fmt, con); \
if (PyDict_SetItemString(d, #con, value) < 0) { \
Py_DECREF(value); \
return -1; \
} \
Py_DECREF(value); \
}

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

static int winapi_exec(PyObject *m)
{
WinApiState *st = winapi_get_state(m);
Expand All @@ -1934,6 +1928,7 @@ static int winapi_exec(PyObject *m)
return -1;
}

Py_INCREF(st->overlapped_type);
if (PyModule_AddObject(m, "Overlapped", (PyObject *)st->overlapped_type) < 0) {
Py_DECREF(st->overlapped_type);
return -1;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.