diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-04-16 18:55:50 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-04-16 18:55:50 (GMT) |
commit | 19ab6c98cf0525682b74f1f217503c42bacb4916 (patch) | |
tree | 085bf98c3a76a80475ef8864ac329c820286ad04 /Modules/resource.c | |
parent | d18d5a31535f4162045ce7b7ac8ea320333d24d4 (diff) | |
download | cpython-19ab6c98cf0525682b74f1f217503c42bacb4916.zip cpython-19ab6c98cf0525682b74f1f217503c42bacb4916.tar.gz cpython-19ab6c98cf0525682b74f1f217503c42bacb4916.tar.bz2 |
Initialize structseq types only once.
Diffstat (limited to 'Modules/resource.c')
-rw-r--r-- | Modules/resource.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/resource.c b/Modules/resource.c index 7cbd2c9..e73c878 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -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; } |