Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rebased update
  • Loading branch information
vmuriart authored and yagweb committed Apr 7, 2017
commit add5ba8fe7ad4ef7c73ec0a3ea980a033d05e905
12 changes: 6 additions & 6 deletions src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public class PySessionDisposedException: Exception
{

}

public class PyScope : IDisposable
{
public class GILState : IDisposable
Expand Down Expand Up @@ -698,7 +698,7 @@ public PyObject ImportAs(string name, string asname)
public PyObject Execute(PyObject script)
{
IntPtr ptr = Runtime.PyEval_EvalCode(script.Handle, globals, locals);
Py.Throw();
Runtime.CheckExceptionOccurred();
if(ptr == Runtime.PyNone)
{
Runtime.XDecref(ptr);
Expand Down Expand Up @@ -728,7 +728,7 @@ public PyObject Compile(string code, string filename = "", RunFlagType mode = Ru
{
IntPtr flag = (IntPtr)mode;
IntPtr ptr = Runtime.Py_CompileString(code, filename, flag);
Py.Throw();
Runtime.CheckExceptionOccurred();
return new PyObject(ptr);
}

Expand All @@ -746,7 +746,7 @@ public PyObject Eval(string code)
IntPtr ptr = Runtime.PyRun_String(
code, flag, globals, locals
);
Py.Throw();
Runtime.CheckExceptionOccurred();
return new PyObject(ptr);
}

Expand Down Expand Up @@ -774,14 +774,14 @@ public void Exec(string code)
this.AcquireLock();
Exec(code, this.globals, this.locals);
}

private void Exec(string code, IntPtr _globals, IntPtr _locals)
{
var flag = (IntPtr)Runtime.Py_file_input;
IntPtr ptr = Runtime.PyRun_String(
code, flag, _globals, _locals
);
Py.Throw();
Runtime.CheckExceptionOccurred();
if (ptr != Runtime.PyNone)
{
throw new PythonException();
Expand Down
6 changes: 2 additions & 4 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,8 @@ public static extern int Py_Main(
[DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyRun_String(string code, IntPtr st, IntPtr globals, IntPtr locals);

[DllImport(PythonDll, CallingConvention = CallingConvention.Cdecl,
ExactSpelling = true, CharSet = CharSet.Ansi)]
internal unsafe static extern IntPtr
PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);
[DllImport(PythonDll)]
internal static extern IntPtr PyEval_EvalCode(IntPtr co, IntPtr globals, IntPtr locals);

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