Skip to content

Commit 8febfbf

Browse files
committed
Fix test_embed.
1 parent 1761c37 commit 8febfbf

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

Programs/_testembed.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,9 +1424,12 @@ static int test_audit_subinterpreter(void)
14241424
PySys_AddAuditHook(_audit_subinterpreter_hook, NULL);
14251425
_testembed_Py_InitializeFromConfig();
14261426

1427-
Py_NewInterpreter();
1428-
Py_NewInterpreter();
1429-
Py_NewInterpreter();
1427+
PyThreadState *tstate = PyThreadState_Get();
1428+
for (int i = 0; i < 3; ++i)
1429+
{
1430+
Py_EndInterpreter(Py_NewInterpreter());
1431+
PyThreadState_Swap(tstate);
1432+
}
14301433

14311434
Py_Finalize();
14321435

Python/pylifecycle.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,9 +2414,8 @@ Py_NewInterpreter(void)
24142414
return tstate;
24152415
}
24162416

2417-
/* Delete an interpreter and its last thread. This requires that the
2418-
given thread state is current, that the thread has no remaining
2419-
frames, and that it is its interpreter's only remaining thread.
2417+
/* Delete an interpreter. This requires that the given thread state
2418+
is current, and that the thread has no remaining frames.
24202419
It is a fatal error to violate these constraints.
24212420
24222421
(Py_FinalizeEx() doesn't have these constraints -- it zaps

0 commit comments

Comments
 (0)