diff options
Diffstat (limited to 'Modules/resource.c')
-rw-r--r-- | Modules/resource.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/Modules/resource.c b/Modules/resource.c index b294a8c..8768315 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -263,80 +263,83 @@ PyInit_resource(void) /* Add some symbolic constants to the module */ Py_INCREF(PyExc_OSError); PyModule_AddObject(m, "error", PyExc_OSError); - if (!initialized) - PyStructSequence_InitType(&StructRUsageType, - &struct_rusage_desc); + if (!initialized) { + if (PyStructSequence_InitType2(&StructRUsageType, + &struct_rusage_desc) < 0) + return NULL; + } + Py_INCREF(&StructRUsageType); PyModule_AddObject(m, "struct_rusage", (PyObject*) &StructRUsageType); /* insert constants */ #ifdef RLIMIT_CPU - PyModule_AddIntConstant(m, "RLIMIT_CPU", RLIMIT_CPU); + PyModule_AddIntMacro(m, RLIMIT_CPU); #endif #ifdef RLIMIT_FSIZE - PyModule_AddIntConstant(m, "RLIMIT_FSIZE", RLIMIT_FSIZE); + PyModule_AddIntMacro(m, RLIMIT_FSIZE); #endif #ifdef RLIMIT_DATA - PyModule_AddIntConstant(m, "RLIMIT_DATA", RLIMIT_DATA); + PyModule_AddIntMacro(m, RLIMIT_DATA); #endif #ifdef RLIMIT_STACK - PyModule_AddIntConstant(m, "RLIMIT_STACK", RLIMIT_STACK); + PyModule_AddIntMacro(m, RLIMIT_STACK); #endif #ifdef RLIMIT_CORE - PyModule_AddIntConstant(m, "RLIMIT_CORE", RLIMIT_CORE); + PyModule_AddIntMacro(m, RLIMIT_CORE); #endif #ifdef RLIMIT_NOFILE - PyModule_AddIntConstant(m, "RLIMIT_NOFILE", RLIMIT_NOFILE); + PyModule_AddIntMacro(m, RLIMIT_NOFILE); #endif #ifdef RLIMIT_OFILE - PyModule_AddIntConstant(m, "RLIMIT_OFILE", RLIMIT_OFILE); + PyModule_AddIntMacro(m, RLIMIT_OFILE); #endif #ifdef RLIMIT_VMEM - PyModule_AddIntConstant(m, "RLIMIT_VMEM", RLIMIT_VMEM); + PyModule_AddIntMacro(m, RLIMIT_VMEM); #endif #ifdef RLIMIT_AS - PyModule_AddIntConstant(m, "RLIMIT_AS", RLIMIT_AS); + PyModule_AddIntMacro(m, RLIMIT_AS); #endif #ifdef RLIMIT_RSS - PyModule_AddIntConstant(m, "RLIMIT_RSS", RLIMIT_RSS); + PyModule_AddIntMacro(m, RLIMIT_RSS); #endif #ifdef RLIMIT_NPROC - PyModule_AddIntConstant(m, "RLIMIT_NPROC", RLIMIT_NPROC); + PyModule_AddIntMacro(m, RLIMIT_NPROC); #endif #ifdef RLIMIT_MEMLOCK - PyModule_AddIntConstant(m, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK); + PyModule_AddIntMacro(m, RLIMIT_MEMLOCK); #endif #ifdef RLIMIT_SBSIZE - PyModule_AddIntConstant(m, "RLIMIT_SBSIZE", RLIMIT_SBSIZE); + PyModule_AddIntMacro(m, RLIMIT_SBSIZE); #endif #ifdef RUSAGE_SELF - PyModule_AddIntConstant(m, "RUSAGE_SELF", RUSAGE_SELF); + PyModule_AddIntMacro(m, RUSAGE_SELF); #endif #ifdef RUSAGE_CHILDREN - PyModule_AddIntConstant(m, "RUSAGE_CHILDREN", RUSAGE_CHILDREN); + PyModule_AddIntMacro(m, RUSAGE_CHILDREN); #endif #ifdef RUSAGE_BOTH - PyModule_AddIntConstant(m, "RUSAGE_BOTH", RUSAGE_BOTH); + PyModule_AddIntMacro(m, RUSAGE_BOTH); #endif #ifdef RUSAGE_THREAD - PyModule_AddIntConstant(m, "RUSAGE_THREAD", RUSAGE_THREAD); + PyModule_AddIntMacro(m, RUSAGE_THREAD); #endif #if defined(HAVE_LONG_LONG) |