bpo-43687: Py_Initialize() creates singletons earlier (GH-25147)
Reorganize pycore_interp_init() to initialize singletons before the
the first PyType_Ready() call. Fix an issue when Python is configured
using --without-doc-strings.
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 178f7b2..b3c41b1 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1968,7 +1968,7 @@ PyTypeObject PyFloat_Type = {
.tp_vectorcall = (vectorcallfunc)float_vectorcall,
};
-int
+void
_PyFloat_Init(void)
{
/* We attempt to determine if this machine is using IEEE
@@ -2016,14 +2016,18 @@ _PyFloat_Init(void)
double_format = detected_double_format;
float_format = detected_float_format;
+}
+int
+_PyFloat_InitTypes(void)
+{
/* Init float info */
if (FloatInfoType.tp_name == NULL) {
if (PyStructSequence_InitType2(&FloatInfoType, &floatinfo_desc) < 0) {
- return 0;
+ return -1;
}
}
- return 1;
+ return 0;
}
void