|
189 | 189 | import com.oracle.graal.python.builtins.objects.object.PythonObject;
|
190 | 190 | import com.oracle.graal.python.builtins.objects.str.PString;
|
191 | 191 | import com.oracle.graal.python.builtins.objects.traceback.GetTracebackNode;
|
192 |
| -import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback; |
193 | 192 | import com.oracle.graal.python.builtins.objects.traceback.PTraceback;
|
194 | 193 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
195 | 194 | import com.oracle.graal.python.builtins.objects.tuple.StructSequence;
|
|
249 | 248 | import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode;
|
250 | 249 | import com.oracle.graal.python.runtime.PythonContext.PythonThreadState;
|
251 | 250 | import com.oracle.graal.python.runtime.PythonOptions;
|
252 |
| -import com.oracle.graal.python.runtime.exception.ExceptionUtils; |
253 | 251 | import com.oracle.graal.python.runtime.exception.PException;
|
254 | 252 | import com.oracle.graal.python.runtime.exception.PythonErrorType;
|
255 | 253 | import com.oracle.graal.python.runtime.object.PythonObjectFactory;
|
@@ -637,129 +635,9 @@ static boolean isDecoratedManagedFunction(Object obj) {
|
637 | 635 | }
|
638 | 636 | }
|
639 | 637 |
|
640 |
| - @Builtin(name = "PyErr_Restore", minNumOfPositionalArgs = 3) |
641 |
| - @GenerateNodeFactory |
642 |
| - abstract static class PyErrRestoreNode extends PythonTernaryBuiltinNode { |
643 |
| - @Specialization |
644 |
| - @SuppressWarnings("unused") |
645 |
| - Object run(PNone typ, PNone val, PNone tb) { |
646 |
| - getContext().setCurrentException(getLanguage(), null); |
647 |
| - return PNone.NONE; |
648 |
| - } |
649 |
| - |
650 |
| - @Specialization |
651 |
| - Object run(@SuppressWarnings("unused") Object typ, PBaseException val, @SuppressWarnings("unused") PNone tb) { |
652 |
| - PythonContext context = getContext(); |
653 |
| - PythonLanguage language = getLanguage(); |
654 |
| - context.setCurrentException(language, PException.fromExceptionInfo(val, (LazyTraceback) null, PythonOptions.isPExceptionWithJavaStacktrace(language))); |
655 |
| - return PNone.NONE; |
656 |
| - } |
657 |
| - |
658 |
| - @Specialization |
659 |
| - Object run(@SuppressWarnings("unused") Object typ, PBaseException val, PTraceback tb) { |
660 |
| - PythonContext context = getContext(); |
661 |
| - PythonLanguage language = getLanguage(); |
662 |
| - context.setCurrentException(language, PException.fromExceptionInfo(val, tb, PythonOptions.isPExceptionWithJavaStacktrace(language))); |
663 |
| - return PNone.NONE; |
664 |
| - } |
665 |
| - } |
666 |
| - |
667 |
| - @Builtin(name = "PyErr_Fetch") |
668 |
| - @GenerateNodeFactory |
669 |
| - abstract static class PyErrFetchNode extends NativeBuiltin { |
670 |
| - @Specialization |
671 |
| - public Object run(@Cached GetThreadStateNode getThreadStateNode, |
672 |
| - @Cached GetClassNode getClassNode, |
673 |
| - @Cached GetTracebackNode getTracebackNode) { |
674 |
| - PException currentException = getThreadStateNode.getCurrentException(); |
675 |
| - Object result; |
676 |
| - if (currentException == null) { |
677 |
| - result = getContext().getNativeNull(); |
678 |
| - } else { |
679 |
| - PBaseException exception = currentException.getEscapedException(); |
680 |
| - Object traceback = null; |
681 |
| - if (currentException.getTraceback() != null) { |
682 |
| - traceback = getTracebackNode.execute(currentException.getTraceback()); |
683 |
| - } |
684 |
| - if (traceback == null) { |
685 |
| - traceback = getContext().getNativeNull(); |
686 |
| - } |
687 |
| - result = factory().createTuple(new Object[]{getClassNode.execute(exception), exception, traceback}); |
688 |
| - getThreadStateNode.setCurrentException(null); |
689 |
| - } |
690 |
| - return result; |
691 |
| - } |
692 |
| - } |
693 |
| - |
694 |
| - @Builtin(name = "PyErr_Occurred", maxNumOfPositionalArgs = 1) |
695 |
| - @GenerateNodeFactory |
696 |
| - abstract static class PyErrOccurred extends PythonUnaryBuiltinNode { |
697 |
| - @Specialization |
698 |
| - static Object run(Object errorMarker, |
699 |
| - @Cached GetThreadStateNode getThreadStateNode, |
700 |
| - @Cached GetClassNode getClassNode) { |
701 |
| - PException currentException = getThreadStateNode.getCurrentException(); |
702 |
| - if (currentException != null) { |
703 |
| - // getClassNode acts as a branch profile |
704 |
| - return getClassNode.execute(currentException.getUnreifiedException()); |
705 |
| - } |
706 |
| - return errorMarker; |
707 |
| - } |
708 |
| - } |
709 |
| - |
710 |
| - @Builtin(name = "PyErr_SetExcInfo", minNumOfPositionalArgs = 3) |
711 |
| - @GenerateNodeFactory |
712 |
| - abstract static class PyErrSetExcInfo extends PythonBuiltinNode { |
713 |
| - @Specialization |
714 |
| - @SuppressWarnings("unused") |
715 |
| - Object doClear(PNone typ, PNone val, PNone tb) { |
716 |
| - getContext().setCaughtException(getLanguage(), PException.NO_EXCEPTION); |
717 |
| - return PNone.NONE; |
718 |
| - } |
719 |
| - |
720 |
| - @Specialization |
721 |
| - Object doFull(@SuppressWarnings("unused") Object typ, PBaseException val, PTraceback tb) { |
722 |
| - PythonContext context = getContext(); |
723 |
| - PythonLanguage language = getLanguage(); |
724 |
| - context.setCaughtException(language, PException.fromExceptionInfo(val, tb, PythonOptions.isPExceptionWithJavaStacktrace(language))); |
725 |
| - return PNone.NONE; |
726 |
| - } |
727 |
| - |
728 |
| - @Specialization |
729 |
| - Object doWithoutTraceback(@SuppressWarnings("unused") Object typ, PBaseException val, @SuppressWarnings("unused") PNone tb) { |
730 |
| - return doFull(typ, val, null); |
731 |
| - } |
732 |
| - |
733 |
| - @Fallback |
734 |
| - @SuppressWarnings("unused") |
735 |
| - static Object doFallback(Object typ, Object val, Object tb) { |
736 |
| - // TODO we should still store the values to return them with 'PyErr_GetExcInfo' (or |
737 |
| - // 'sys.exc_info') |
738 |
| - return PNone.NONE; |
739 |
| - } |
740 |
| - } |
741 |
| - |
742 |
| - /** |
743 |
| - * Exceptions are usually printed using the traceback module or the hook function |
744 |
| - * {@code sys.excepthook}. This is the last resort if the hook function itself failed. |
745 |
| - */ |
746 |
| - @Builtin(name = "PyErr_Display", minNumOfPositionalArgs = 3) |
747 |
| - @GenerateNodeFactory |
748 |
| - abstract static class PyErrDisplay extends PythonBuiltinNode { |
749 |
| - |
750 |
| - @Specialization |
751 |
| - @SuppressWarnings("unused") |
752 |
| - static Object run(Object typ, PBaseException val, Object tb) { |
753 |
| - if (val.getException() != null) { |
754 |
| - ExceptionUtils.printPythonLikeStackTrace(val.getException()); |
755 |
| - } |
756 |
| - return PNone.NO_VALUE; |
757 |
| - } |
758 |
| - } |
759 |
| - |
760 | 638 | @Builtin(name = "PyTruffle_WriteUnraisable", minNumOfPositionalArgs = 2)
|
761 | 639 | @GenerateNodeFactory
|
762 |
| - abstract static class PyTruffleWriteUnraisable extends PythonBuiltinNode { |
| 640 | + abstract static class PyTruffleWriteUnraisable extends PythonBinaryBuiltinNode { |
763 | 641 |
|
764 | 642 | @Specialization
|
765 | 643 | static Object run(PBaseException exception, Object object,
|
|
0 commit comments