diff options
author | Victor Stinner <vstinner@python.org> | 2022-01-22 17:55:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-22 17:55:48 (GMT) |
commit | 500c146387b01ea797b52e6a54caf228384e184c (patch) | |
tree | b10c015f37540da45ed534d0b4f9711c12a19f3e /Python | |
parent | 1f8014c5b4ea7acee069ca453f6fbcad5990ebf0 (diff) | |
download | cpython-500c146387b01ea797b52e6a54caf228384e184c.zip cpython-500c146387b01ea797b52e6a54caf228384e184c.tar.gz cpython-500c146387b01ea797b52e6a54caf228384e184c.tar.bz2 |
bpo-46417: Clear more static types (GH-30796)
* Move PyContext static types into object.c static_types list.
* Rename PyContextTokenMissing_Type to _PyContextTokenMissing_Type
and declare it in pycore_context.h.
* _PyHamtItems types are no long exported: replace PyAPI_DATA() with
extern.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 5 | ||||
-rw-r--r-- | Python/context.c | 19 | ||||
-rw-r--r-- | Python/hamt.c | 21 | ||||
-rw-r--r-- | Python/pylifecycle.c | 2 |
4 files changed, 4 insertions, 43 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ecd8be1..ed61209 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2986,11 +2986,6 @@ _PyBuiltin_Init(PyInterpreterState *interp) const PyConfig *config = _PyInterpreterState_GetConfig(interp); - if (PyType_Ready(&PyFilter_Type) < 0 || - PyType_Ready(&PyMap_Type) < 0 || - PyType_Ready(&PyZip_Type) < 0) - return NULL; - mod = _PyModule_CreateInitialized(&builtinsmodule, PYTHON_API_VERSION); if (mod == NULL) return NULL; diff --git a/Python/context.c b/Python/context.c index 9ed73b7..f3033d9 100644 --- a/Python/context.c +++ b/Python/context.c @@ -1260,7 +1260,7 @@ context_token_missing_tp_repr(PyObject *self) } -PyTypeObject PyContextTokenMissing_Type = { +PyTypeObject _PyContextTokenMissing_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "Token.MISSING", sizeof(PyContextTokenMissing), @@ -1279,7 +1279,7 @@ get_token_missing(void) } _token_missing = (PyObject *)PyObject_New( - PyContextTokenMissing, &PyContextTokenMissing_Type); + PyContextTokenMissing, &_PyContextTokenMissing_Type); if (_token_missing == NULL) { return NULL; } @@ -1323,25 +1323,12 @@ _PyContext_Fini(PyInterpreterState *interp) PyStatus -_PyContext_InitTypes(PyInterpreterState *interp) +_PyContext_Init(PyInterpreterState *interp) { if (!_Py_IsMainInterpreter(interp)) { return _PyStatus_OK(); } - PyStatus status = _PyHamt_InitTypes(interp); - if (_PyStatus_EXCEPTION(status)) { - return status; - } - - if ((PyType_Ready(&PyContext_Type) < 0) || - (PyType_Ready(&PyContextVar_Type) < 0) || - (PyType_Ready(&PyContextToken_Type) < 0) || - (PyType_Ready(&PyContextTokenMissing_Type) < 0)) - { - return _PyStatus_ERR("can't init context types"); - } - PyObject *missing = get_token_missing(); if (PyDict_SetItemString( PyContextToken_Type.tp_dict, "MISSING", missing)) diff --git a/Python/hamt.c b/Python/hamt.c index 8c8e025..cbfe445 100644 --- a/Python/hamt.c +++ b/Python/hamt.c @@ -2953,27 +2953,6 @@ PyTypeObject _PyHamt_CollisionNode_Type = { }; -PyStatus -_PyHamt_InitTypes(PyInterpreterState *interp) -{ - if (!_Py_IsMainInterpreter(interp)) { - return _PyStatus_OK(); - } - - if ((PyType_Ready(&_PyHamt_Type) < 0) || - (PyType_Ready(&_PyHamt_ArrayNode_Type) < 0) || - (PyType_Ready(&_PyHamt_BitmapNode_Type) < 0) || - (PyType_Ready(&_PyHamt_CollisionNode_Type) < 0) || - (PyType_Ready(&_PyHamtKeys_Type) < 0) || - (PyType_Ready(&_PyHamtValues_Type) < 0) || - (PyType_Ready(&_PyHamtItems_Type) < 0)) - { - return _PyStatus_ERR("can't init hamt types"); - } - - return _PyStatus_OK(); -} - void _PyHamt_Fini(PyInterpreterState *interp) { diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 662e578..a53f532 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -760,7 +760,7 @@ pycore_init_types(PyInterpreterState *interp) return status; } - status = _PyContext_InitTypes(interp); + status = _PyContext_Init(interp); if (_PyStatus_EXCEPTION(status)) { return status; } |