Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit add5ba8

Browse files
vmuriartyagweb
authored andcommitted
Rebased update
1 parent 9f50e25 commit add5ba8

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/runtime/pythonengine.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public class PySessionDisposedException: Exception
531531
{
532532

533533
}
534-
534+
535535
public class PyScope : IDisposable
536536
{
537537
public class GILState : IDisposable
@@ -698,7 +698,7 @@ public PyObject ImportAs(string name, string asname)
698698
public PyObject Execute(PyObject script)
699699
{
700700
IntPtr ptr = Runtime.PyEval_EvalCode(script.Handle, globals, locals);
701-
Py.Throw();
701+
Runtime.CheckExceptionOccurred();
702702
if(ptr == Runtime.PyNone)
703703
{
704704
Runtime.XDecref(ptr);
@@ -728,7 +728,7 @@ public PyObject Compile(string code, string filename = "", RunFlagType mode = Ru
728728
{
729729
IntPtr flag = (IntPtr)mode;
730730
IntPtr ptr = Runtime.Py_CompileString(code, filename, flag);
731-
Py.Throw();
731+
Runtime.CheckExceptionOccurred();
732732
return new PyObject(ptr);
733733
}
734734

@@ -746,7 +746,7 @@ public PyObject Eval(string code)
746746
IntPtr ptr = Runtime.PyRun_String(
747747
code, flag, globals, locals
748748
);
749-
Py.Throw();
749+
Runtime.CheckExceptionOccurred();
750750
return new PyObject(ptr);
751751
}
752752

@@ -774,14 +774,14 @@ public void Exec(string code)
774774
this.AcquireLock();
775775
Exec(code, this.globals, this.locals);
776776
}
777-
777+
778778
private void Exec(string code, IntPtr _globals, IntPtr _locals)
779779
{
780780
var flag = (IntPtr)Runtime.Py_file_input;
781781
IntPtr ptr = Runtime.PyRun_String(
782782
code, flag, _globals, _locals
783783
);
784-
Py.Throw();
784+
Runtime.CheckExceptionOccurred();
785785
if (ptr != Runtime.PyNone)
786786
{
787787
throw new PythonException();

src/runtime/runtime.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,10 +707,8 @@ public static extern int Py_Main(
707707
[DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
708708
internal static extern IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals);
709709

710-
[DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
711-
ExactSpelling = true, CharSet = CharSet.Ansi)]
712-
internal unsafe static extern IntPtr
713-
PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);
710+
[DllImport(PythonDll)]
711+
internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);
714712

715713
[DllImport(PythonDll)]
716714
internal static extern IntPtr Py_CompileString(string code, string file, IntPtr tok);

0 commit comments

Comments
 (0)