bpo-38631: Avoid Py_FatalError() in init_slotdefs() (GH-18263)

Rename init_slotdefs() to _PyTypes_InitSlotDefs() and add a return
value of type PyStatus. The function is now called exactly once from
_PyTypes_Init(). Replace calls to init_slotdefs() with an assertion
checking that slotdefs is initialized.
This commit is contained in:
Victor Stinner 2020-01-30 09:02:14 +01:00 committed by GitHub
parent 5eb8bff7e4
commit 7a1f6c2da4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 16 deletions

View file

@ -6,6 +6,7 @@
#include "pycore_initconfig.h"
#include "pycore_object.h"
#include "pycore_pyerrors.h"
#include "pycore_pylifecycle.h"
#include "pycore_pystate.h"
#include "frameobject.h"
#include "interpreteridobject.h"
@ -1841,6 +1842,11 @@ PyObject _Py_NotImplementedStruct = {
PyStatus
_PyTypes_Init(void)
{
PyStatus status = _PyTypes_InitSlotDefs();
if (_PyStatus_EXCEPTION(status)) {
return status;
}
#define INIT_TYPE(TYPE, NAME) \
do { \
if (PyType_Ready(TYPE) < 0) { \