Skip to content

Commit 8d52258

Browse files
Call _PyObject_InitState() *after* computing the feature flags.
1 parent ffe2633 commit 8d52258

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Python/pylifecycle.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,16 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
674674
return status;
675675
}
676676

677+
// Ideally we would call this in _PyInterpreterState_New(), but it
678+
// requires interp->feature_flags to be correctly set already.
679+
// That mwans we'd have to compute the feature flags before
680+
// creating the interpreter and passing them in there, which we
681+
// should probably be doing anyway.
682+
status = _PyObject_InitState(interp);
683+
if (_PyStatus_EXCEPTION(status)) {
684+
return status;
685+
}
686+
677687
// initialize the interp->obmalloc state. This must be done after
678688
// the settings are loaded (so that feature_flags are set) but before
679689
// any calls are made to obmalloc functions.

Python/pystate.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,9 @@ init_interpreter(PyInterpreterState *interp,
629629
assert(next != NULL || (interp == runtime->interpreters.main));
630630
interp->next = next;
631631

632-
PyStatus status = _PyObject_InitState(interp);
633-
if (_PyStatus_EXCEPTION(status)) {
634-
return status;
635-
}
632+
// We would call _PyObject_InitState() here, but it needs the
633+
// interp->feature_flags to be correctly set already, which we don't
634+
// currently do.
636635

637636
_PyEval_InitState(interp);
638637
_PyGC_InitState(&interp->gc);

0 commit comments

Comments
 (0)