8000 bpo-1635741: Port resource extension module to multiphase initialization(PEP 489) by shihai1991 · Pull Request #19252 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-1635741: Port resource extension module to multiphase initialization(PEP 489) #19252

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 8 commits into from
Apr 2, 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
Simplify the code
  • Loading branch information
shihai1991 committed Apr 2, 2020
commit 7a8297697712c364abac3433b2ff8a84ef7d0bd6
23 changes: 17 additions & 6 deletions Modules/resource.c
8000
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ resource_methods[] = {

static int resource_exec(PyObject *module)
{
#define ADD_INT(module, value) \
do { \
if (PyModule_AddIntMacro(module, value) < 0) { \
return -1; \
} \
} while (0) \

PyObject *v;

/* Add some symbolic constants to the module */
Expand Down Expand Up @@ -478,16 +485,20 @@ static int resource_exec(PyObject *module)
{
v = PyLong_FromLong((long) RLIM_INFINITY);
}
if (v) {
if (PyModule_AddObject(module, "RLIM_INFINITY", v) < 0) {
Py_DECREF(v);
return -1;
}
} else {

if (!v) {
return -1;
}

if (PyModule_AddObject(module, "RLIM_INFINITY", v) < 0) {
Py_DECREF(v);
return -1;
}

initialized = 1;
return 0;

#undef ADD_INT
}

static struct PyModuleDef_Slot resource_slots[] = {
Expand Down
0