Skip to content

Commit 1f1a1a8

Browse files
author
Adam Hrbac
committed
Simplify logic in the case we aren't tracing
1 parent 967ee0b commit 1f1a1a8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/TracingTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ public void ensureBytecode() {
5252
Assume.assumeTrue(PythonTests.usingBytecodeCompiler());
5353
}
5454

55+
@Test
56+
public void traceInExistingScopeWithOnlyReturn() {
57+
String source = "import sys\n" +
58+
"def trace(fr, ev, arg): print(fr.f_lineno, ev); return trace\n" +
59+
"def fun():\n" +
60+
" sys._getframe().f_trace = trace\n" +
61+
" sys.settrace(lambda:None)\n" +
62+
"fun()";
63+
PythonTests.assertPrints("5 return\n", source);
64+
}
65+
5566
@Test
5667
public void traceCall() {
5768
String source = "import sys\n" +

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod
11191119
initialBci == 0 ? getFirstLineno() : (mutableData.pastLine = bciToLine(initialBci)), false);
11201120
}
11211121

1122-
mutableData.returnLine = mutableData.pastLine;
1123-
mutableData.pastBci = initialBci;
1122+
mutableData.returnLine = -1;
11241123

11251124
int oparg = 0;
11261125
while (true) {

0 commit comments

Comments
 (0)