Core and builtins
-----------------
+- All uses of PyStructSequence_InitType have been changed to initialize
+ the type objects only once, even if the interpreter is initialized
+ multiple times.
+
- Bug #1454485, array.array('u') could crash the interpreter. This was
due to PyArgs_ParseTuple(args, 'u#', ...) trying to convert buffers (strings)
to unicode when it didn't make sense. 'u#' now requires a unicode string.
5
};
+static int initialized;
static PyTypeObject StatsEntryType;
static PyTypeObject StatsSubEntryType;
return;
PyDict_SetItemString(d, "Profiler", (PyObject *)&PyProfiler_Type);
- PyStructSequence_InitType(&StatsEntryType, &profiler_entry_desc);
- PyStructSequence_InitType(&StatsSubEntryType, &profiler_subentry_desc);
+ if (!initialized) {
+ PyStructSequence_InitType(&StatsEntryType,
+ &profiler_entry_desc);
+ PyStructSequence_InitType(&StatsSubEntryType,
+ &profiler_subentry_desc);
+ }
Py_INCREF((PyObject*) &StatsEntryType);
Py_INCREF((PyObject*) &StatsSubEntryType);
PyModule_AddObject(module, "profiler_entry",
PyModule_AddObject(module, "profiler_subentry",
(PyObject*) &StatsSubEntryType);
empty_tuple = PyTuple_New(0);
+ initialized = 1;
}
};
+static int initialized;
static PyTypeObject StructGrpType;
static PyObject *
if (m == NULL)
return;
d = PyModule_GetDict(m);
- PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc);
+ if (!initialized)
+ PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc);
PyDict_SetItemString(d, "struct_group", (PyObject *) &StructGrpType);
+ initialized = 1;
}
10
};
+static int initialized;
static PyTypeObject StatResultType;
static PyTypeObject StatVFSResultType;
static newfunc structseq_new;
posix_putenv_garbage = PyDict_New();
#endif
- stat_result_desc.name = MODNAME ".stat_result";
- stat_result_desc.fields[7].name = PyStructSequence_UnnamedField;
- stat_result_desc.fields[8].name = PyStructSequence_UnnamedField;
- stat_result_desc.fields[9].name = PyStructSequence_UnnamedField;
- PyStructSequence_InitType(&StatResultType, &stat_result_desc);
- structseq_new = StatResultType.tp_new;
- StatResultType.tp_new = statresult_new;
+ if (!initialized) {
+ stat_result_desc.name = MODNAME ".stat_result";
+ stat_result_desc.fields[7].name = PyStructSequence_UnnamedField;
+ stat_result_desc.fields[8].name = PyStructSequence_UnnamedField;
+ stat_result_desc.fields[9].name = PyStructSequence_UnnamedField;
+ PyStructSequence_InitType(&StatResultType, &stat_result_desc);
+ structseq_new = StatResultType.tp_new;
+ StatResultType.tp_new = statresult_new;
+
+ statvfs_result_desc.name = MODNAME ".statvfs_result";
+ PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
+ }
Py_INCREF((PyObject*) &StatResultType);
PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType);
-
- statvfs_result_desc.name = MODNAME ".statvfs_result";
- PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
Py_INCREF((PyObject*) &StatVFSResultType);
PyModule_AddObject(m, "statvfs_result",
(PyObject*) &StatVFSResultType);
+ initialized = 1;
}
#ifdef __cplusplus
exception is raised if the entry asked for cannot be found.");
+static int initialized;
static PyTypeObject StructPwdType;
static void
if (m == NULL)
return;
- PyStructSequence_InitType(&StructPwdType, &struct_pwd_type_desc);
+ if (!initialized)
+ PyStructSequence_InitType(&StructPwdType,
+ &struct_pwd_type_desc);
Py_INCREF((PyObject *) &StructPwdType);
PyModule_AddObject(m, "struct_passwd", (PyObject *) &StructPwdType);
/* And for b/w compatibility (this was defined by mistake): */
PyModule_AddObject(m, "struct_pwent", (PyObject *) &StructPwdType);
+ initialized = 1;
}
16 /* n_in_sequence */
};
+static int initialized;
static PyTypeObject StructRUsageType;
static PyObject *
}
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);
if (v) {
PyModule_AddObject(m, "RLIM_INFINITY", v);
}
+ initialized = 1;
}
9,
};
+static int initialized;
static PyTypeObject StructSpwdType;
m=Py_InitModule3("spwd", spwd_methods, spwd__doc__);
if (m == NULL)
return;
- PyStructSequence_InitType(&StructSpwdType, &struct_spwd_type_desc);
+ if (!initialized)
+ PyStructSequence_InitType(&StructSpwdType,
+ &struct_spwd_type_desc);
Py_INCREF((PyObject *) &StructSpwdType);
PyModule_AddObject(m, "struct_spwd", (PyObject *) &StructSpwdType);
+ initialized = 1;
}
9,
};
+static int initialized;
static PyTypeObject StructTimeType;
static PyObject *
hInterruptEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
SetConsoleCtrlHandler( PyCtrlHandler, TRUE);
#endif /* MS_WINDOWS */
- PyStructSequence_InitType(&StructTimeType, &struct_time_type_desc);
+ if (!initialized) {
+ PyStructSequence_InitType(&StructTimeType,
+ &struct_time_type_desc);
+ }
Py_INCREF(&StructTimeType);
PyModule_AddObject(m, "struct_time", (PyObject*) &StructTimeType);
+ initialized = 1;
}