@@ -919,6 +919,7 @@ static PyMemberDef frame_memberlist[] = {
919919};
920920
921921/*[clinic input]
922+ @critical_section
922923@getter
923924frame.f_locals as frame_locals
924925
@@ -927,7 +928,7 @@ Return the mapping used by the frame to look up local variables.
927928
928929static PyObject *
929930frame_locals_get_impl (PyFrameObject * self )
930- /*[clinic end generated code: output=b4ace8bb4cae71f4 input=badf3ad13216129f ]*/
931+ /*[clinic end generated code: output=b4ace8bb4cae71f4 input=7bd444d0dc8ddf44 ]*/
931932{
932933 assert (!_PyFrame_IsIncomplete (self -> f_frame ));
933934
@@ -989,6 +990,7 @@ frame_lineno_get_impl(PyFrameObject *self)
989990}
990991
991992/*[clinic input]
993+ @critical_section
992994@getter
993995frame.f_lasti as frame_lasti
994996
@@ -997,7 +999,7 @@ Return the index of the last attempted instruction in the frame.
997999
9981000static PyObject *
9991001frame_lasti_get_impl (PyFrameObject * self )
1000- /*[clinic end generated code: output=03275b4f0327d1a2 input=50404c3d0708e39e ]*/
1002+ /*[clinic end generated code: output=03275b4f0327d1a2 input=0225ed49cb1fbeeb ]*/
10011003{
10021004 int lasti = _PyInterpreterFrame_LASTI (self -> f_frame );
10031005 if (lasti < 0 ) {
@@ -1982,14 +1984,15 @@ frame_clear_impl(PyFrameObject *self)
19821984}
19831985
19841986/*[clinic input]
1987+ @critical_section
19851988frame.__sizeof__
19861989
19871990Return the size of the frame in memory, in bytes.
19881991[clinic start generated code]*/
19891992
19901993static PyObject *
19911994frame___sizeof___impl (PyFrameObject * self )
1992- /*[clinic end generated code: output=82948688e81078e2 input=1a07b2d6a8e166a5 ]*/
1995+ /*[clinic end generated code: output=82948688e81078e2 input=908f90a83e73131d ]*/
19931996{
19941997 Py_ssize_t res ;
19951998 res = offsetof(PyFrameObject , _f_frame_data ) + offsetof(_PyInterpreterFrame , localsplus );
@@ -2379,21 +2382,18 @@ PyFrame_GetBuiltins(PyFrameObject *frame)
23792382int
23802383PyFrame_GetLasti (PyFrameObject * frame )
23812384{
2385+ int ret ;
2386+ Py_BEGIN_CRITICAL_SECTION (frame );
23822387 assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
23832388 int lasti = _PyInterpreterFrame_LASTI (frame -> f_frame );
2384- if (lasti < 0 ) {
2385- return -1 ;
2386- }
2387- return lasti * sizeof (_Py_CODEUNIT );
2389+ ret = lasti < 0 ? -1 : lasti * sizeof (_Py_CODEUNIT );
2390+ Py_END_CRITICAL_SECTION ();
2391+ return ret ;
23882392}
23892393
23902394PyObject *
23912395PyFrame_GetGenerator (PyFrameObject * frame )
23922396{
23932397 assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
2394- if (frame -> f_frame -> owner != FRAME_OWNED_BY_GENERATOR ) {
2395- return NULL ;
2396- }
2397- PyGenObject * gen = _PyGen_GetGeneratorFromFrame (frame -> f_frame );
2398- return Py_NewRef (gen );
2398+ return frame_generator_get ((PyObject * )frame , NULL );
23992399}
0 commit comments