mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Initialize structseq types only once.
This commit is contained in:
parent
d18d5a3153
commit
19ab6c98cf
8 changed files with 52 additions and 17 deletions
|
@ -55,6 +55,7 @@ static PyStructSequence_Desc struct_rusage_desc = {
|
|||
16 /* n_in_sequence */
|
||||
};
|
||||
|
||||
static int initialized;
|
||||
static PyTypeObject StructRUsageType;
|
||||
|
||||
static PyObject *
|
||||
|
@ -244,7 +245,10 @@ initresource(void)
|
|||
}
|
||||
Py_INCREF(ResourceError);
|
||||
PyModule_AddObject(m, "error", ResourceError);
|
||||
PyStructSequence_InitType(&StructRUsageType, &struct_rusage_desc);
|
||||
if (!initialized)
|
||||
PyStructSequence_InitType(&StructRUsageType,
|
||||
&struct_rusage_desc);
|
||||
Py_INCREF(&StructRUsageType);
|
||||
PyModule_AddObject(m, "struct_rusage",
|
||||
(PyObject*) &StructRUsageType);
|
||||
|
||||
|
@ -320,4 +324,5 @@ initresource(void)
|
|||
if (v) {
|
||||
PyModule_AddObject(m, "RLIM_INFINITY", v);
|
||||
}
|
||||
initialized = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue