@@ -590,6 +590,7 @@ first_line_not_before(int *lines, int len, int line)
590
590
static PyFrameState
591
591
_PyFrame_GetState (PyFrameObject * frame )
592
592
{
593
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
593
594
if (frame -> f_frame -> stacktop == 0 ) {
594
595
return FRAME_CLEARED ;
595
596
}
@@ -1063,6 +1064,9 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
1063
1064
init_frame ((_PyInterpreterFrame * )f -> _f_frame_data , func , locals );
1064
1065
f -> f_frame = (_PyInterpreterFrame * )f -> _f_frame_data ;
1065
1066
f -> f_frame -> owner = FRAME_OWNED_BY_FRAME_OBJECT ;
1067
+ // This frame needs to be "complete", so pretend that the first RESUME ran:
1068
+ f -> f_frame -> prev_instr = _PyCode_CODE (code ) + code -> _co_firsttraceable ;
1069
+ assert (!_PyFrame_IsIncomplete (f -> f_frame ));
1066
1070
Py_DECREF (func );
1067
1071
_PyObject_GC_TRACK (f );
1068
1072
return f ;
@@ -1189,6 +1193,7 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
1189
1193
int
1190
1194
PyFrame_FastToLocalsWithError (PyFrameObject * f )
1191
1195
{
1196
+ assert (!_PyFrame_IsIncomplete (f -> f_frame ));
1192
1197
if (f == NULL ) {
1193
1198
PyErr_BadInternalCall ();
1194
1199
return -1 ;
@@ -1204,7 +1209,7 @@ void
1204
1209
PyFrame_FastToLocals (PyFrameObject * f )
1205
1210
{
1206
1211
int res ;
1207
-
1212
+ assert (! _PyFrame_IsIncomplete ( f -> f_frame ));
1208
1213
assert (!PyErr_Occurred ());
1209
1214
1210
1215
res = PyFrame_FastToLocalsWithError (f );
@@ -1282,6 +1287,7 @@ _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
1282
1287
void
1283
1288
PyFrame_LocalsToFast (PyFrameObject * f , int clear )
1284
1289
{
1290
+ assert (!_PyFrame_IsIncomplete (f -> f_frame ));
1285
1291
if (f && f -> f_fast_as_locals && _PyFrame_GetState (f ) != FRAME_CLEARED ) {
1286
1292
_PyFrame_LocalsToFast (f -> f_frame , clear );
1287
1293
f -> f_fast_as_locals = 0 ;
@@ -1292,6 +1298,7 @@ PyFrame_LocalsToFast(PyFrameObject *f, int clear)
1292
1298
int _PyFrame_IsEntryFrame (PyFrameObject * frame )
1293
1299
{
1294
1300
assert (frame != NULL );
1301
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1295
1302
return frame -> f_frame -> is_entry ;
1296
1303
}
1297
1304
@@ -1300,6 +1307,7 @@ PyCodeObject *
1300
1307
PyFrame_GetCode (PyFrameObject * frame )
1301
1308
{
1302
1309
assert (frame != NULL );
1310
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1303
1311
PyCodeObject * code = frame -> f_frame -> f_code ;
1304
1312
assert (code != NULL );
1305
1313
Py_INCREF (code );
@@ -1311,6 +1319,7 @@ PyFrameObject*
1311
1319
PyFrame_GetBack (PyFrameObject * frame )
1312
1320
{
1313
1321
assert (frame != NULL );
1322
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1314
1323
PyFrameObject * back = frame -> f_back ;
1315
1324
if (back == NULL ) {
1316
1325
_PyInterpreterFrame * prev = frame -> f_frame -> previous ;
@@ -1328,24 +1337,28 @@ PyFrame_GetBack(PyFrameObject *frame)
1328
1337
PyObject *
1329
1338
PyFrame_GetLocals (PyFrameObject * frame )
1330
1339
{
1340
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1331
1341
return frame_getlocals (frame , NULL );
1332
1342
}
1333
1343
1334
1344
PyObject *
1335
1345
PyFrame_GetGlobals (PyFrameObject * frame )
1336
1346
{
1347
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1337
1348
return frame_getglobals (frame , NULL );
1338
1349
}
1339
1350
1340
1351
PyObject *
1341
1352
PyFrame_GetBuiltins (PyFrameObject * frame )
1342
1353
{
1354
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1343
1355
return frame_getbuiltins (frame , NULL );
1344
1356
}
1345
1357
1346
1358
int
1347
1359
PyFrame_GetLasti (PyFrameObject * frame )
1348
1360
{
1361
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1349
1362
int lasti = _PyInterpreterFrame_LASTI (frame -> f_frame );
1350
1363
if (lasti < 0 ) {
1351
1364
return -1 ;
@@ -1356,6 +1369,7 @@ PyFrame_GetLasti(PyFrameObject *frame)
1356
1369
PyObject *
1357
1370
PyFrame_GetGenerator (PyFrameObject * frame )
1358
1371
{
1372
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1359
1373
if (frame -> f_frame -> owner != FRAME_OWNED_BY_GENERATOR ) {
1360
1374
return NULL ;
1361
1375
}
0 commit comments