Skip to content

Commit 415f081

Browse files
committed
Revert "Don't try and re-lock the generator to clear it."
This reverts commit 770ce09.
1 parent 81e90bf commit 415f081

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Python/ceval.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,12 +1741,7 @@ clear_gen_frame(PyThreadState *tstate, _PyInterpreterFrame * frame)
17411741
{
17421742
assert(frame->owner == FRAME_OWNED_BY_GENERATOR);
17431743
PyGenObject *gen = _PyGen_GetGeneratorFromFrame(frame);
1744-
/* It's safe to assume that the generator is locked, because this
1745-
* was eventually called by something that locked it already.
1746-
*
1747-
* In fact, trying to lock the generator here ends up breaking
1748-
* the critical section API. */
1749-
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(gen);
1744+
Py_BEGIN_CRITICAL_SECTION(gen);
17501745
gen->gi_frame_state = FRAME_CLEARED;
17511746
assert(tstate->exc_info == &gen->gi_exc_state);
17521747
tstate->exc_info = gen->gi_exc_state.previous_item;
@@ -1757,6 +1752,7 @@ clear_gen_frame(PyThreadState *tstate, _PyInterpreterFrame * frame)
17571752
_PyErr_ClearExcState(&gen->gi_exc_state);
17581753
tstate->c_recursion_remaining++;
17591754
frame->previous = NULL;
1755+
Py_END_CRITICAL_SECTION();
17601756
}
17611757

17621758
void

0 commit comments

Comments
 (0)