gh-94673: Fix _PyTypes_InitTypes() and get_type_attr_as_size() (gh-103961)

This change has two small parts:

1. a follow-up to gh-103940 with one case I missed
2. adding a missing return that I noticed while working on related code
This commit is contained in:
Eric Snow 2023-04-27 18:28:51 -06:00 committed by GitHub
parent d2e2e53f73
commit 424a785a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 4 deletions

View File

@ -2102,10 +2102,6 @@ static PyTypeObject* static_types[] = {
PyStatus PyStatus
_PyTypes_InitTypes(PyInterpreterState *interp) _PyTypes_InitTypes(PyInterpreterState *interp)
{ {
if (!_Py_IsMainInterpreter(interp)) {
return _PyStatus_OK();
}
// All other static types (unless initialized elsewhere) // All other static types (unless initialized elsewhere)
for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) { for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) {
PyTypeObject *type = static_types[i]; PyTypeObject *type = static_types[i];

View File

@ -31,6 +31,7 @@ get_type_attr_as_size(PyTypeObject *tp, PyObject *name)
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"Missed attribute '%U' of type %s", "Missed attribute '%U' of type %s",
name, tp->tp_name); name, tp->tp_name);
return -1;
} }
return PyLong_AsSsize_t(v); return PyLong_AsSsize_t(v);
} }