mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-46008: Make runtime-global object/type lifecycle functions and state consistent. (gh-29998)
This change is strictly renames and moving code around. It helps in the following ways: * ensures type-related init functions focus strictly on one of the three aspects (state, objects, types) * passes in PyInterpreterState * to all those functions, simplifying work on moving types/objects/state to the interpreter * consistent naming conventions help make what's going on more clear * keeping API related to a type in the corresponding header file makes it more obvious where to look for it https://bugs.python.org/issue46008
This commit is contained in:
parent
d8a464ef03
commit
c8749b5783
38 changed files with 818 additions and 361 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_dtoa.h" // _Py_dg_dtoa()
|
||||
#include "pycore_floatobject.h" // _PyFloat_FormatAdvancedWriter()
|
||||
#include "pycore_initconfig.h" // _PyStatus_OK()
|
||||
#include "pycore_interp.h" // _PyInterpreterState.float_state
|
||||
#include "pycore_long.h" // _PyLong_GetOne()
|
||||
#include "pycore_object.h" // _PyObject_Init()
|
||||
|
@ -1981,8 +1982,12 @@ PyTypeObject PyFloat_Type = {
|
|||
};
|
||||
|
||||
void
|
||||
_PyFloat_Init(void)
|
||||
_PyFloat_InitState(PyInterpreterState *interp)
|
||||
{
|
||||
if (!_Py_IsMainInterpreter(interp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* We attempt to determine if this machine is using IEEE
|
||||
floating point formats by peering at the bits of some
|
||||
carefully chosen values. If it looks like we are on an
|
||||
|
@ -2030,16 +2035,25 @@ _PyFloat_Init(void)
|
|||
float_format = detected_float_format;
|
||||
}
|
||||
|
||||
int
|
||||
_PyFloat_InitTypes(void)
|
||||
PyStatus
|
||||
_PyFloat_InitTypes(PyInterpreterState *interp)
|
||||
{
|
||||
if (!_Py_IsMainInterpreter(interp)) {
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
|
||||
if (PyType_Ready(&PyFloat_Type) < 0) {
|
||||
return _PyStatus_ERR("Can't initialize float type");
|
||||
}
|
||||
|
||||
/* Init float info */
|
||||
if (FloatInfoType.tp_name == NULL) {
|
||||
if (PyStructSequence_InitType2(&FloatInfoType, &floatinfo_desc) < 0) {
|
||||
return -1;
|
||||
return _PyStatus_ERR("can't init float info type");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue