@@ -588,6 +588,7 @@ first_line_not_before(int *lines, int len, int line)
588
588
static PyFrameState
589
589
_PyFrame_GetState (PyFrameObject * frame )
590
590
{
591
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
591
592
if (frame -> f_frame -> stacktop == 0 ) {
592
593
return FRAME_CLEARED ;
593
594
}
@@ -1094,6 +1095,9 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
1094
1095
init_frame ((_PyInterpreterFrame * )f -> _f_frame_data , func , locals );
1095
1096
f -> f_frame = (_PyInterpreterFrame * )f -> _f_frame_data ;
1096
1097
f -> f_frame -> owner = FRAME_OWNED_BY_FRAME_OBJECT ;
1098
+ // This frame needs to be "complete", so pretend that the first RESUME ran:
1099
+ f -> f_frame -> prev_instr = _PyCode_CODE (code ) + code -> _co_firsttraceable ;
1100
+ assert (!_PyFrame_IsIncomplete (f -> f_frame ));
1097
1101
Py_DECREF (func );
1098
1102
_PyObject_GC_TRACK (f );
1099
1103
return f ;
@@ -1222,6 +1226,7 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
1222
1226
int
1223
1227
PyFrame_FastToLocalsWithError (PyFrameObject * f )
1224
1228
{
1229
+ assert (!_PyFrame_IsIncomplete (f -> f_frame ));
1225
1230
if (f == NULL ) {
1226
1231
PyErr_BadInternalCall ();
1227
1232
return -1 ;
@@ -1237,7 +1242,7 @@ void
1237
1242
PyFrame_FastToLocals (PyFrameObject * f )
1238
1243
{
1239
1244
int res ;
1240
-
1245
+ assert (! _PyFrame_IsIncomplete ( f -> f_frame ));
1241
1246
assert (!PyErr_Occurred ());
1242
1247
1243
1248
res = PyFrame_FastToLocalsWithError (f );
@@ -1320,6 +1325,7 @@ _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
1320
1325
void
1321
1326
PyFrame_LocalsToFast (PyFrameObject * f , int clear )
1322
1327
{
1328
+ assert (!_PyFrame_IsIncomplete (f -> f_frame ));
1323
1329
if (f && f -> f_fast_as_locals && _PyFrame_GetState (f ) != FRAME_CLEARED ) {
1324
1330
_PyFrame_LocalsToFast (f -> f_frame , clear );
1325
1331
f -> f_fast_as_locals = 0 ;
@@ -1330,6 +1336,7 @@ PyFrame_LocalsToFast(PyFrameObject *f, int clear)
1330
1336
int _PyFrame_IsEntryFrame (PyFrameObject * frame )
1331
1337
{
1332
1338
assert (frame != NULL );
1339
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1333
1340
return frame -> f_frame -> is_entry ;
1334
1341
}
1335
1342
@@ -1338,6 +1345,7 @@ PyCodeObject *
1338
1345
PyFrame_GetCode (PyFrameObject * frame )
1339
1346
{
1340
1347
assert (frame != NULL );
1348
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1341
1349
PyCodeObject * code = frame -> f_frame -> f_code ;
1342
1350
assert (code != NULL );
1343
1351
Py_INCREF (code );
@@ -1349,6 +1357,7 @@ PyFrameObject*
1349
1357
PyFrame_GetBack (PyFrameObject * frame )
1350
1358
{
1351
1359
assert (frame != NULL );
1360
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1352
1361
PyFrameObject * back = frame -> f_back ;
1353
1362
if (back == NULL ) {
1354
1363
_PyInterpreterFrame * prev = frame -> f_frame -> previous ;
@@ -1366,24 +1375,28 @@ PyFrame_GetBack(PyFrameObject *frame)
1366
1375
PyObject *
1367
1376
PyFrame_GetLocals (PyFrameObject * frame )
1368
1377
{
1378
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1369
1379
return frame_getlocals (frame , NULL );
1370
1380
}
1371
1381
1372
1382
PyObject *
1373
1383
PyFrame_GetGlobals (PyFrameObject * frame )
1374
1384
{
1385
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1375
1386
return frame_getglobals (frame , NULL );
1376
1387
}
1377
1388
1378
1389
PyObject *
1379
1390
PyFrame_GetBuiltins (PyFrameObject * frame )
1380
1391
{
1392
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1381
1393
return frame_getbuiltins (frame , NULL );
1382
1394
}
1383
1395
1384
1396
int
1385
1397
PyFrame_GetLasti (PyFrameObject * frame )
1386
1398
{
1399
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1387
1400
int lasti = _PyInterpreterFrame_LASTI (frame -> f_frame );
1388
1401
if (lasti < 0 ) {
1389
1402
return -1 ;
@@ -1394,6 +1407,7 @@ PyFrame_GetLasti(PyFrameObject *frame)
1394
1407
PyObject *
1395
1408
PyFrame_GetGenerator (PyFrameObject * frame )
1396
1409
{
1410
+ assert (!_PyFrame_IsIncomplete (frame -> f_frame ));
1397
1411
if (frame -> f_frame -> owner != FRAME_OWNED_BY_GENERATOR ) {
1398
1412
return NULL ;
1399
1413
}
0 commit comments