Skip to content

Commit b52f0ca

Browse files
committed
refactor: move PrintTracebackNode to lib and rename to PyTraceBackPrintNode
1 parent 65bea11 commit b52f0ca

File tree

2 files changed

+170
-178
lines changed

2 files changed

+170
-178
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@
5252
import static com.oracle.graal.python.builtins.modules.CodecsModuleBuiltins.BACKSLASHREPLACE;
5353
import static com.oracle.graal.python.builtins.modules.CodecsModuleBuiltins.STRICT;
5454
import static com.oracle.graal.python.builtins.modules.io.IONodes.WRITE;
55-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.castToString;
56-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.classNameNoDot;
57-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.fileFlush;
58-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.fileWriteString;
59-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.getExceptionTraceback;
60-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.getObjectClass;
61-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.getTypeName;
62-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.longAsInt;
63-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.objectHasAttr;
64-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.objectLookupAttr;
65-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.objectLookupAttrAsString;
66-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.objectRepr;
67-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.objectStr;
68-
import static com.oracle.graal.python.builtins.objects.traceback.TracebackNodes.tryCastToString;
55+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.castToString;
56+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.classNameNoDot;
57+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.fileFlush;
58+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.fileWriteString;
59+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.getExceptionTraceback;
60+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.getObjectClass;
61+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.getTypeName;
62+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.longAsInt;
63+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.objectHasAttr;
64+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.objectLookupAttr;
65+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.objectLookupAttrAsString;
66+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.objectRepr;
67+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.objectStr;
68+
import static com.oracle.graal.python.lib.PyTraceBackPrintNode.tryCastToString;
6969
import static com.oracle.graal.python.nodes.BuiltinNames.BREAKPOINTHOOK;
7070
import static com.oracle.graal.python.nodes.BuiltinNames.BUILTINS;
7171
import static com.oracle.graal.python.nodes.BuiltinNames.DISPLAYHOOK;
@@ -106,6 +106,7 @@
106106
import java.util.Map;
107107
import java.util.Set;
108108

109+
import com.oracle.graal.python.lib.PyTraceBackPrintNode;
109110
import org.graalvm.nativeimage.ImageInfo;
110111

111112
import com.oracle.graal.python.PythonLanguage;
@@ -141,7 +142,6 @@
141142
import com.oracle.graal.python.builtins.objects.traceback.GetTracebackNode;
142143
import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback;
143144
import com.oracle.graal.python.builtins.objects.traceback.PTraceback;
144-
import com.oracle.graal.python.builtins.objects.traceback.TracebackNodes;
145145
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
146146
import com.oracle.graal.python.builtins.objects.tuple.StructSequence;
147147
import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins;
@@ -894,32 +894,32 @@ static Object gettrace() {
894894
"* object: Object causing the exception, can be None.")
895895
@GenerateNodeFactory
896896
abstract static class UnraisableHookNode extends PythonBuiltinNode {
897-
@Child private TracebackNodes.PrintTracebackNode printTracebackNode;
897+
@Child private PyTraceBackPrintNode pyTraceBackPrintNode;
898898

899899
private void printTraceBack(VirtualFrame frame, PythonModule sys, Object out, Object tb) {
900-
if (printTracebackNode == null) {
900+
if (pyTraceBackPrintNode == null) {
901901
CompilerDirectives.transferToInterpreterAndInvalidate();
902-
printTracebackNode = insert(TracebackNodes.PrintTracebackNode.create());
902+
pyTraceBackPrintNode = insert(PyTraceBackPrintNode.create());
903903
}
904-
printTracebackNode.execute(frame, sys, out, tb);
904+
pyTraceBackPrintNode.execute(frame, sys, out, tb);
905905
}
906906

907907
private void writeUnraisableExc(MaterializedFrame frame, PythonModule sys, Object out,
908908
Object excType, Object excValue, Object excTb, Object errMsg, Object obj) {
909909
if (obj != PNone.NONE) {
910910
if (errMsg != PNone.NONE) {
911-
TracebackNodes.fileWriteObject(frame, out, errMsg, true);
911+
PyTraceBackPrintNode.fileWriteObject(frame, out, errMsg, true);
912912
fileWriteString(frame, out, ": ");
913913
} else {
914914
fileWriteString(frame, out, "Exception ignored in: ");
915915
}
916916

917-
if (!TracebackNodes.fileWriteObject(frame, out, obj, false)) {
917+
if (!PyTraceBackPrintNode.fileWriteObject(frame, out, obj, false)) {
918918
fileWriteString(frame, out, "<object repr() failed>");
919919
}
920920
fileWriteString(frame, out, NEW_LINE);
921921
} else if (errMsg != PNone.NONE) {
922-
TracebackNodes.fileWriteObject(frame, out, errMsg, true);
922+
PyTraceBackPrintNode.fileWriteObject(frame, out, errMsg, true);
923923
fileWriteString(frame, out, ":\n");
924924
}
925925

@@ -958,7 +958,7 @@ private void writeUnraisableExc(MaterializedFrame frame, PythonModule sys, Objec
958958
if (excValue != PNone.NONE) {
959959
// only print colon if the str() of the object is not the empty string
960960
fileWriteString(frame, out, ": ");
961-
if (!TracebackNodes.fileWriteObject(frame, out, excValue, true)) {
961+
if (!PyTraceBackPrintNode.fileWriteObject(frame, out, excValue, true)) {
962962
fileWriteString(frame, out, "<exception str() failed>");
963963
}
964964
}
@@ -1002,14 +1002,14 @@ abstract static class ExceptHookNode extends PythonBuiltinNode {
10021002
static final String ATTR_OFFSET = "offset";
10031003
static final String ATTR_TEXT = "text";
10041004

1005-
@Child private TracebackNodes.PrintTracebackNode printTracebackNode;
1005+
@Child private PyTraceBackPrintNode pyTraceBackPrintNode;
10061006

10071007
private void printTraceBack(VirtualFrame frame, PythonModule sys, Object out, Object tb) {
1008-
if (printTracebackNode == null) {
1008+
if (pyTraceBackPrintNode == null) {
10091009
CompilerDirectives.transferToInterpreterAndInvalidate();
1010-
printTracebackNode = insert(TracebackNodes.PrintTracebackNode.create());
1010+
pyTraceBackPrintNode = insert(PyTraceBackPrintNode.create());
10111011
}
1012-
printTracebackNode.execute(frame, sys, out, tb);
1012+
pyTraceBackPrintNode.execute(frame, sys, out, tb);
10131013
}
10141014

10151015
@CompilerDirectives.ValueType

0 commit comments

Comments
 (0)