@@ -502,7 +502,7 @@ public class PySessionDisposedException: Exception
502502 {
503503
504504 }
505-
505+
506506 public class PyScope : IDisposable
507507 {
508508 public class GILState : IDisposable
@@ -669,7 +669,7 @@ public PyObject ImportAs(string name, string asname)
669669 public PyObject Execute ( PyObject script )
670670 {
671671 IntPtr ptr = Runtime . PyEval_EvalCode ( script . Handle , globals , locals ) ;
672- Py . Throw ( ) ;
672+ Runtime . CheckExceptionOccurred ( ) ;
673673 if ( ptr == Runtime . PyNone )
674674 {
675675 Runtime . XDecref ( ptr ) ;
@@ -699,7 +699,7 @@ public PyObject Compile(string code, string filename = "", RunFlagType mode = Ru
699699 {
700700 IntPtr flag = ( IntPtr ) mode ;
701701 IntPtr ptr = Runtime . Py_CompileString ( code , filename , flag ) ;
702- Py . Throw ( ) ;
702+ Runtime . CheckExceptionOccurred ( ) ;
703703 return new PyObject ( ptr ) ;
704704 }
705705
@@ -717,7 +717,7 @@ public PyObject Eval(string code)
717717 IntPtr ptr = Runtime . PyRun_String (
718718 code , flag , globals , locals
719719 ) ;
720- Py . Throw ( ) ;
720+ Runtime . CheckExceptionOccurred ( ) ;
721721 return new PyObject ( ptr ) ;
722722 }
723723
@@ -745,14 +745,14 @@ public void Exec(string code)
745745 this . AcquireLock ( ) ;
746746 Exec ( code , this . globals , this . locals ) ;
747747 }
748-
748+
749749 private void Exec ( string code , IntPtr _globals , IntPtr _locals )
750750 {
751751 var flag = ( IntPtr ) Runtime . Py_file_input ;
752752 IntPtr ptr = Runtime . PyRun_String (
753753 code , flag , _globals , _locals
754754 ) ;
755- Py . Throw ( ) ;
755+ Runtime . CheckExceptionOccurred ( ) ;
756756 if ( ptr != Runtime . PyNone )
757757 {
758758 throw new PythonException ( ) ;
0 commit comments