8000 bpo-34784: Posixmodule: Heap StructSequence by eduardo-elizondo · Pull Request #9665 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-34784: Posixmodule: Heap StructSequence #9665

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 12 commits into from
Nov 13, 2018
Prev Previous commit
Also update posixmodule if braces
  • Loading branch information
eduardo-elizondo committed Nov 6, 2018
commit 43e92faa90b796421625954489966c0ca09a0ad0
21 changes: 14 additions & 7 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -13913,24 +13913,27 @@ INITFUNC(void)
#if defined(HAVE_WAITID) && !defined(__APPLE__)
waitid_result_desc.name = MODNAME ".waitid_result";
WaitidResultType = PyStructSequence_NewType(&waitid_result_desc);
if (WaitidResultType == NULL)
if (WaitidResultType == NULL) {
return NULL;
}
#endif

stat_result_desc.name = "os.stat_result"; /* see issue #19209 */
stat_result_desc.fields[7].name = PyStructSequence_UnnamedField;
stat_result_desc.fields[8].name = PyStructSequence_UnnamedField;
stat_result_desc.fields[9].name = PyStructSequence_UnnamedField;
StatResultType = PyStructSequence_NewType(&stat_result_desc);
if (StatResultType == NULL)
if (StatResultType == NULL) {
return NULL;
}
structseq_new = StatResultType->tp_new;
StatResultType->tp_new = statresult_new;

statvfs_result_desc.name = "os.statvfs_result"; /* see issue #19209 */
StatVFSResultType = PyStructSequence_NewType(&statvfs_result_desc);
if (StatVFSResultType == NULL)
if (StatVFSResultType == NULL) {
return NULL;
}
#ifdef NEED_TICKS_PER_SECOND
# if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
ticks_per_second = sysconf(_SC_CLK_TCK);
Expand All @@ -13944,15 +13947,17 @@ INITFUNC(void)
#if defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)
sched_param_desc.name = MODNAME ".sched_param";
SchedParamType = PyStructSequence_NewType(&sched_param_desc);
if (SchedParamType == NULL)
if (SchedParamType == NULL) {
return NULL;
}
SchedParamType->tp_new = os_sched_param;
#endif

/* initialize TerminalSize_info */
TerminalSizeType = PyStructSequence_NewType(&TerminalSize_desc);
if (TerminalSizeType == NULL)
if (TerminalSizeType == NULL) {
return NULL;
}

/* initialize scandir types */
if (PyType_Ready(&ScandirIteratorType) < 0)
Expand All @@ -13977,14 +13982,16 @@ INITFUNC(void)

times_result_desc.name = MODNAME ".times_result";
TimesResultType = PyStructSequence_NewType(&times_result_desc);
if (TimesResultType == NULL)
if (TimesResultType == NULL) {
return NULL;
}
PyModule_AddObject(m, "times_result", (PyObject *)TimesResultType);

uname_result_desc.name = MODNAME ".uname_result";
UnameResultType = PyStructSequence_NewType(&uname_result_desc);
if (UnameResultType == NULL)
if (UnameResultType == NULL) {
return NULL;
}
PyModule_AddObject(m, "uname_result", (PyObject *)UnameResultType);

#ifdef __APPLE__
Expand Down
4 changes: 2 additions & 2 deletions Objects/structseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)

/* PyTypeObject has already been initialized */
if (Py_REFCNT(type) != 0) {
PyErr_BadInternalCall();
return -1;
PyErr_BadInternalCall();
return -1;
}

type->tp_name = desc->name;
Expand Down
0