mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
5eb8bff7e4
commit
7a1f6c2da4
3 changed files with 26 additions and 16 deletions
|
@ -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) { \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue