Skip to content

Commit bfd6c0c

Browse files
committed
Fix traceback handling in yield from
1 parent 5a70ba0 commit bfd6c0c

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/GetTracebackNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@
101101
* <li>When you catch a {@link PException PException} and need to obtain its corresponding
102102
* {@link com.oracle.graal.python.builtins.objects.exception.PBaseException PBaseException}, use the
103103
* {@link PException#setCatchingFrameAndGetEscapedException(VirtualFrame, Node)} method, unless
104-
* you're just doing a simple class check. Try to avoid the {@link PException#getUnreifiedException()
105-
* getExceptionObject} method unless you know what you're doing.</li>
104+
* you're just doing a simple class check. Try to avoid the
105+
* {@link PException#getUnreifiedException() getExceptionObject} method unless you know what you're
106+
* doing.</li>
106107
* <li>{@link PException PException} must never be rethrown after it has been possibly exposed to
107108
* the program, because its Truffle stacktrace may already be frozen and it would not capture more
108109
* frames. If you need to rethrow without the catching site appearing in the traceback, use

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/generator/YieldFromNode.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@
4242

4343
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4444
import com.oracle.graal.python.builtins.objects.PNone;
45-
import com.oracle.graal.python.builtins.objects.exception.PBaseException;
4645
import com.oracle.graal.python.builtins.objects.function.PArguments;
4746
import com.oracle.graal.python.builtins.objects.generator.ThrowData;
4847
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
49-
import com.oracle.graal.python.builtins.objects.traceback.GetTracebackNode;
5048
import com.oracle.graal.python.nodes.WriteUnraisableNode;
5149
import com.oracle.graal.python.nodes.attributes.GetAttributeNode;
5250
import com.oracle.graal.python.nodes.call.CallNode;
@@ -76,7 +74,6 @@ public class YieldFromNode extends AbstractYieldNode implements GeneratorControl
7674
@Child private GetAttributeNode getSendNode;
7775
@Child private CallNode callSendNode;
7876

79-
@Child private GetTracebackNode getTracebackNode;
8077
@Child private WriteUnraisableNode writeUnraisableNode;
8178

8279
@Child private IsBuiltinClassProfile stopIterProfile1 = IsBuiltinClassProfile.create();
@@ -176,12 +173,7 @@ public Object execute(VirtualFrame frame) {
176173
throw PException.fromObject(_e.pythonException, this, _e.withJavaStacktrace);
177174
}
178175
try {
179-
PBaseException pythonException = _e.pythonException;
180-
Object excTraceback = ensureGetTracebackNode().execute(pythonException.getTraceback());
181-
if (excTraceback == null) {
182-
excTraceback = PNone.NONE;
183-
}
184-
_y = getCallThrowNode().execute(frame, _m, pythonException, PNone.NONE, excTraceback);
176+
_y = getCallThrowNode().execute(frame, _m, _e.pythonException);
185177
} catch (PException _e2) {
186178
access.setIterator(frame, iteratorSlot, null);
187179
_e2.expectStopIteration(stopIterProfile2);
@@ -276,14 +268,6 @@ private CallNode getCallSendNode() {
276268
return callSendNode;
277269
}
278270

279-
private GetTracebackNode ensureGetTracebackNode() {
280-
if (getTracebackNode == null) {
281-
CompilerDirectives.transferToInterpreterAndInvalidate();
282-
getTracebackNode = insert(GetTracebackNode.create());
283-
}
284-
return getTracebackNode;
285-
}
286-
287271
private WriteUnraisableNode ensureWriteUnraisable() {
288272
if (writeUnraisableNode == null) {
289273
CompilerDirectives.transferToInterpreterAndInvalidate();

0 commit comments

Comments
 (0)