8000 Address review comments. · python/cpython@e76f241 · GitHub
[go: up one dir, main page]

Skip to content

Commit e76f241

Browse files
committed
Address review comments.
1 parent 1da7272 commit e76f241

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Python/ceval.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
775775

776776
#include "generated_cases.c.h"
777777

778+
/* INSTRUMENTED_LINE has to be here, rather than in bytecodes.c,
779+
* because it needs to capture frame->prev_instr before it is updated,
780+
* as happens in the standard instruction prologue.
781+
*/
778782
#if USE_COMPUTED_GOTOS
779783
TARGET_INSTRUMENTED_LINE:
780784
#else

Python/instrumentation.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ _Py_call_instrumentation_jump(
10251025
return NULL;
10261026
}
10271027
if (frame->prev_instr != target) {
1028+
/* The callback has caused a jump (by setting the line number) */
10281029
return frame->prev_instr;
10291030
}
10301031
/* Reset prev_instr for INSTRUMENTED_LINE */
@@ -1294,6 +1295,12 @@ initialize_lines(PyCodeObject *code)
12941295
line_data[i].original_opcode = 0;
12951296
break;
12961297
default:
1298+
/* Set original_opcode to the opcode iff the instruction
1299+
* starts a line, and thus should be instrumented.
1300+
* This saves having to perform this check every time the
1301+
* we turn instrumentation on or off, and serves as a sanity
1302+
* check when debugging.
1303+
*/
12971304
if (line != current_line && line >= 0) {
12981305
line_data[i].original_opcode = opcode;
12991306
}
@@ -1322,6 +1329,8 @@ initialize_lines(PyCodeObject *code)
13221329
switch (opcode) {
13231330
case POP_JUMP_IF_FALSE:
13241331
case POP_JUMP_IF_TRUE:
1332+
case POP_JUMP_IF_NONE:
1333+
case POP_JUMP_IF_NOT_NONE:
13251334
case JUMP_FORWARD:
13261335
{
13271336
target = i + oparg;
@@ -1363,6 +1372,10 @@ initialize_lines(PyCodeObject *code)
13631372
int depth_and_lasti;
13641373
scan = parse_varint(scan, &depth_and_lasti);
13651374
int original_opcode = _Py_GetBaseOpcode(code, handler);
1375+
/* Skip if not the start of a line.
1376+
* END_ASYNC_FOR is a bit special as it marks the end of
1377+
* an `async for` loop, which should not generate its own
1378+
* line event. */
13661379
if (line_data[handler].line_delta != NO_LINE &&
13671380
original_opcode != END_ASYNC_FOR) {
13681381
line_data[handler].original_opcode = original_opcode;

0 commit comments

Comments
 (0)
0