Skip to content

Commit 672fdcc

Browse files
timfelppisl
authored andcommitted
remove Python3Core#raise
1 parent 75514ca commit 672fdcc

File tree

18 files changed

+40
-60
lines changed

18 files changed

+40
-60
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -730,18 +730,6 @@ public void registerImportFunc(PMethod func) {
730730
importFunc = func;
731731
}
732732

733-
@Override
734-
@TruffleBoundary
735-
public PException raise(PythonBuiltinClassType type, String format, Object... args) {
736-
PBaseException instance;
737-
if (format != null) {
738-
instance = objectFactory.createBaseException(type, format, args);
739-
} else {
740-
instance = objectFactory.createBaseException(type);
741-
}
742-
throw PException.fromObject(instance, null, PythonOptions.isPExceptionWithJavaStacktrace(getLanguage()));
743-
}
744-
745733
@Override
746734
@TruffleBoundary
747735
public void warn(PythonBuiltinClassType type, String format, Object... args) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
public class ZlibNodes {
9898

99-
/*- Return codes for the compression/decompression functions.
99+
/*- Return codes for the compression/decompression functions.
100100
Negative values are errors, positive values are used for special but normal events. */
101101
public static final int Z_OK = 0;
102102
public static final int Z_STREAM_END = 1;
@@ -439,7 +439,7 @@ static void memError(Object zst, int function, int err, NFIZlibSupport zlibSuppo
439439
@SuppressWarnings("unused")
440440
@Fallback
441441
void fallback(Object zst, int function, int err, NFIZlibSupport zlibSupport, boolean deallocate) {
442-
throw PythonContext.get(this).getCore().raise(SystemError, "Unhandled Error!");
442+
throw PRaiseNode.raiseUncached(this, SystemError, "Unhandled Error!");
443443
}
444444
}
445445

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public static StringBuilder decodeEscapes(ParserErrorCallback errors, String str
403403

404404
i++;
405405
if (i >= length) {
406-
throw errors.raise(ValueError, ErrorMessages.TRAILING_S_IN_STR, "\\");
406+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.TRAILING_S_IN_STR, "\\");
407407
}
408408

409409
chr = string.charAt(i);
@@ -488,7 +488,7 @@ public static StringBuilder decodeEscapes(ParserErrorCallback errors, String str
488488
// fall through
489489
}
490490
}
491-
throw errors.raise(ValueError, ErrorMessages.INVALID_ESCAPE_AT, "\\x", i);
491+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.INVALID_ESCAPE_AT, "\\x", i);
492492
default:
493493
if (regexMode) {
494494
if (chr == 'g' || (chr >= '0' && chr <= '9')) {
@@ -497,7 +497,7 @@ public static StringBuilder decodeEscapes(ParserErrorCallback errors, String str
497497
charList.append('\\');
498498
charList.append(chr);
499499
} else {
500-
throw errors.raise(ValueError, ErrorMessages.INVALID_ESCAPE_SEQ_AT, chr, i);
500+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.INVALID_ESCAPE_SEQ_AT, chr, i);
501501
}
502502
} else {
503503
charList.append('\\');

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PythonNativeWrapper.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,9 @@
4848
import com.oracle.truffle.api.Truffle;
4949
import com.oracle.truffle.api.dsl.Cached;
5050
import com.oracle.truffle.api.dsl.Specialization;
51-
import com.oracle.truffle.api.interop.InteropLibrary;
5251
import com.oracle.truffle.api.interop.TruffleObject;
53-
import com.oracle.truffle.api.library.CachedLibrary;
5452
import com.oracle.truffle.api.library.ExportLibrary;
5553
import com.oracle.truffle.api.library.ExportMessage;
56-
import com.oracle.truffle.api.nodes.Node;
5754
import com.oracle.truffle.api.profiles.ConditionProfile;
5855

5956
@ExportLibrary(PythonNativeWrapperLibrary.class)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import com.oracle.graal.python.PythonLanguage;
4848
import com.oracle.graal.python.builtins.objects.PNone;
4949
import com.oracle.graal.python.nodes.ErrorMessages;
50-
import com.oracle.graal.python.runtime.PythonContext;
50+
import com.oracle.graal.python.nodes.PRaiseNode;
5151
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
5252
import com.oracle.truffle.api.CompilerAsserts;
5353
import com.oracle.truffle.api.CompilerDirectives;
@@ -136,7 +136,7 @@ public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object
136136
length = (BigInteger) lengthIn;
137137
if (pySign(length) < 0) {
138138
CompilerDirectives.transferToInterpreter();
139-
throw PythonContext.get(factory).getCore().raise(ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG);
139+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG);
140140
}
141141
if (slice.getStep() == PNone.NONE) {
142142
step = ONE;
@@ -146,7 +146,7 @@ public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object
146146
stepIsNegative = pySign(step) < 0;
147147
if (pySign(step) == 0) {
148148
CompilerDirectives.transferToInterpreter();
149-
throw PythonContext.get(factory).getCore().raise(ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO);
149+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO);
150150
}
151151
}
152152

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PSlice.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.oracle.graal.python.builtins.objects.PNone;
3535
import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
3636
import com.oracle.graal.python.nodes.ErrorMessages;
37-
import com.oracle.graal.python.runtime.PythonContext;
37+
import com.oracle.graal.python.nodes.PRaiseNode;
3838
import com.oracle.truffle.api.CompilerAsserts;
3939
import com.oracle.truffle.api.CompilerDirectives;
4040
import com.oracle.truffle.api.CompilerDirectives.ValueType;
@@ -104,7 +104,7 @@ public SliceInfo(int start, int stop, int step) {
104104
protected static void checkNegative(int length) {
105105
if (length < 0) {
106106
CompilerDirectives.transferToInterpreter();
107-
throw PythonContext.get(null).getCore().raise(ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG);
107+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG);
108108
}
109109
}
110110

@@ -136,7 +136,7 @@ public static SliceInfo computeIndices(Object startIn, Object stopIn, Object ste
136136
stepIsNegative = pySign(step) < 0;
137137
if (pySign(step) == 0) {
138138
CompilerDirectives.transferToInterpreter();
139-
throw PythonContext.get(null).getCore().raise(ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO);
139+
throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO);
140140
}
141141
}
142142

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/PString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
import com.oracle.graal.python.builtins.objects.str.StringNodes.StringMaterializeNode;
3333
import com.oracle.graal.python.builtins.objects.str.StringNodesFactory.StringMaterializeNodeGen;
3434
import com.oracle.graal.python.nodes.ErrorMessages;
35+
import com.oracle.graal.python.nodes.PRaiseNode;
3536
import com.oracle.graal.python.nodes.util.CannotCastException;
3637
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
3738
import com.oracle.graal.python.runtime.GilNode;
38-
import com.oracle.graal.python.runtime.PythonContext;
3939
import com.oracle.graal.python.runtime.sequence.PSequence;
4040
import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
4141
import com.oracle.truffle.api.CompilerDirectives;
@@ -273,7 +273,7 @@ public void setSequenceStorage(SequenceStorage store) {
273273
@SuppressWarnings({"static-method", "unused"})
274274
public static void setItem(int idx, Object value) {
275275
CompilerDirectives.transferToInterpreterAndInvalidate();
276-
PythonContext.get(null).getCore().raise(PythonBuiltinClassType.PString, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT);
276+
throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.PString, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT);
277277
}
278278

279279
@ExportMessage

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/PTuple.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
2929
import com.oracle.graal.python.nodes.ErrorMessages;
30-
import com.oracle.graal.python.runtime.PythonContext;
30+
import com.oracle.graal.python.nodes.PRaiseNode;
3131
import com.oracle.graal.python.runtime.sequence.PSequence;
3232
import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage;
3333
import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
@@ -119,7 +119,7 @@ public void setHash(long hash) {
119119
@SuppressWarnings({"static-method", "unused"})
120120
public static void setItem(int idx, Object value) {
121121
CompilerDirectives.transferToInterpreterAndInvalidate();
122-
PythonContext.get(null).getCore().raise(PythonBuiltinClassType.PTuple, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT);
122+
throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.PTuple, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT);
123123
}
124124

125125
@ExportMessage

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,6 @@ public static boolean validateSlots(Object klassIn) {
760760
}
761761
ReadAttributeFromDynamicObjectNode uncachedReadAttrNode = ReadAttributeFromDynamicObjectNode.getUncached();
762762
final Python3Core core = PythonContext.get(uncachedReadAttrNode).getCore();
763-
PythonLanguage language = core.getLanguage();
764763
Object klass = klassIn;
765764
if (klass instanceof PythonBuiltinClassType) {
766765
PythonBuiltinClassType type = (PythonBuiltinClassType) klass;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ static MroSequenceStorage doNativeClass(PythonNativeClass obj,
415415

416416
@Specialization(replaces = {"doPythonClass", "doBuiltinClass", "doNativeClass"})
417417
@TruffleBoundary
418-
static MroSequenceStorage doSlowPath(Object obj) {
418+
static MroSequenceStorage doSlowPath(Object obj,
419+
@Cached PRaiseNode raise) {
419420
if (obj instanceof PythonManagedClass) {
420421
return doPythonClass((PythonManagedClass) obj, ConditionProfile.getUncached(), ConditionProfile.getUncached(), PythonLanguage.get(null));
421422
} else if (obj instanceof PythonBuiltinClassType) {
@@ -429,7 +430,7 @@ static MroSequenceStorage doSlowPath(Object obj) {
429430
return (MroSequenceStorage) sequenceStorage;
430431
}
431432
}
432-
throw PythonContext.get(getTypeMemeberNode).getCore().raise(PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_MRO_OBJ);
433+
throw raise.raise(PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_MRO_OBJ);
433434
}
434435
throw new IllegalStateException("unknown type " + obj.getClass().getName());
435436
}

0 commit comments

Comments
 (0)