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

Skip to content

Commit 46b6cda

Browse files
committed
Rebased update
1 parent 49af0cd commit 46b6cda

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/runtime/pythonengine.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -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();

src/runtime/runtime.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,8 @@ internal static extern void Py_SetPath(
760760
[DllImport(PythonDll)]
761761
internal static extern IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals);
762762

763-
[DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
764-
ExactSpelling = true, CharSet = CharSet.Ansi)]
765-
internal unsafe static extern IntPtr
766-
PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);
763+
[DllImport(PythonDll)]
764+
internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);
767765

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

0 commit comments

Comments
 (0)