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