File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1741,7 +1741,12 @@ clear_gen_frame(PyThreadState *tstate, _PyInterpreterFrame * frame)
1741
1741
{
1742
1742
assert (frame -> owner == FRAME_OWNED_BY_GENERATOR );
1743
1743
PyGenObject * gen = _PyGen_GetGeneratorFromFrame (frame );
1744
- Py_BEGIN_CRITICAL_SECTION (gen );
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 );
1745
1750
gen -> gi_frame_state = FRAME_CLEARED ;
1746
1751
assert (tstate -> exc_info == & gen -> gi_exc_state );
1747
1752
tstate -> exc_info = gen -> gi_exc_state .previous_item ;
@@ -1752,7 +1757,6 @@ clear_gen_frame(PyThreadState *tstate, _PyInterpreterFrame * frame)
1752
1757
_PyErr_ClearExcState (& gen -> gi_exc_state );
1753
1758
tstate -> c_recursion_remaining ++ ;
1754
1759
frame -> previous = NULL ;
1755
- Py_END_CRITICAL_SECTION ();
1756
1760
}
1757
1761
1758
1762
void
You can’t perform that action at this time.
0 commit comments