@@ -969,6 +969,9 @@ test_outside(PyObject *self)
969
969
{
970
970
PyThreadState * ts = PyThreadState_GET ();
971
971
PyTaskletObject * stmain = ts -> st .main ;
972
+ if (PyTasklet_Scheduled (stmain ) && !PyTasklet_IsCurrent (stmain ))
973
+ RUNTIME_ERROR ("main tasklet is still scheduled" , NULL );
974
+ PyTaskletObject * current ;
972
975
PyCStackObject * initial_stub = ts -> st .initial_stub ;
973
976
PyFrameObject * f = SLP_CURRENT_FRAME (ts );
974
977
int recursion_depth = ts -> recursion_depth ;
@@ -989,7 +992,7 @@ test_outside(PyObject *self)
989
992
ts -> st .nesting_level = 0 ;
990
993
SLP_SET_CURRENT_FRAME (ts , NULL );
991
994
ts -> recursion_depth = 0 ;
992
- slp_current_remove ();
995
+ current = slp_current_remove ();
993
996
while (ts -> st .runcount > 0 ) {
994
997
Py_DECREF (ret );
995
998
ret = PyStackless_Schedule (Py_None , 0 );
@@ -1004,7 +1007,7 @@ test_outside(PyObject *self)
1004
1007
Py_CLEAR (ts -> st .initial_stub );
1005
1008
ts -> st .initial_stub = initial_stub ;
1006
1009
SLP_SET_CURRENT_FRAME (ts , f );
1007
- slp_current_insert (stmain );
1010
+ slp_current_insert (current );
1008
1011
ts -> recursion_depth = recursion_depth ;
1009
1012
ts -> st .nesting_level = nesting_level ;
1010
1013
ts -> st .serial_last_jump = jump ;
0 commit comments