@@ -238,7 +238,7 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true,
238238
239239 LoadSubmodule ( module_globals , "clr.interop" , "interop.py" ) ;
240240
241- LoadMixins ( module_globals ) ;
241+ LoadMixins ( module_globals ) ;
242242
243243 // add the imported module to the clr module, and copy the API functions
244244 // and decorators into the main clr module.
@@ -280,7 +280,7 @@ static void LoadSubmodule(BorrowedReference targetModuleDict, string fullName, s
280280
281281 Assembly assembly = Assembly . GetExecutingAssembly ( ) ;
282282 string pyCode = assembly . ReadStringResource ( resourceName ) ;
283- Exec ( pyCode , module_globals . DangerousGetAddress ( ) , module_globals . DangerousGetAddress ( ) ) ;
283+ Exec ( pyCode , module_globals , module_globals ) ;
284284
285285 Runtime . PyDict_SetItemString ( targetModuleDict , memberName ! , module ) ;
286286 }
@@ -548,11 +548,9 @@ public static PyObject Compile(string code, string filename = "", RunFlagType mo
548548 /// Evaluate a Python expression and returns the result.
549549 /// It's a subset of Python eval function.
550550 /// </remarks>
551- public static PyObject Eval ( string code , IntPtr ? globals = null , IntPtr ? locals = null )
551+ public static PyObject Eval ( string code , PyDict ? globals = null , PyObject ? locals = null )
552552 {
553- var globalsRef = new BorrowedReference ( globals . GetValueOrDefault ( ) ) ;
554- var localsRef = new BorrowedReference ( locals . GetValueOrDefault ( ) ) ;
555- PyObject result = RunString ( code , globalsRef , localsRef , RunFlagType . Eval ) ;
553+ PyObject result = RunString ( code , globals . BorrowNullable ( ) , locals . BorrowNullable ( ) , RunFlagType . Eval ) ;
556554 return result ;
557555 }
558556
@@ -564,11 +562,9 @@ public static PyObject Eval(string code, IntPtr? globals = null, IntPtr? locals
564562 /// Run a string containing Python code.
565563 /// It's a subset of Python exec function.
566564 /// </remarks>
567- public static void Exec ( string code , IntPtr ? globals = null , IntPtr ? locals = null )
565+ public static void Exec ( string code , PyDict ? globals = null , PyObject ? locals = null )
568566 {
569- var globalsRef = new BorrowedReference ( globals . GetValueOrDefault ( ) ) ;
570- var localsRef = new BorrowedReference ( locals . GetValueOrDefault ( ) ) ;
571- using PyObject result = RunString ( code , globalsRef , localsRef , RunFlagType . File ) ;
567+ using PyObject result = RunString ( code , globals . BorrowNullable ( ) , locals . BorrowNullable ( ) , RunFlagType . File ) ;
572568 if ( result . obj != Runtime . PyNone )
573569 {
574570 throw PythonException . ThrowLastAsClrException ( ) ;
@@ -621,9 +617,9 @@ public static int Interrupt(ulong pythonThreadID)
621617 /// Use Exec/Eval/RunSimpleString instead.
622618 /// </summary>
623619 [ Obsolete ( "RunString is deprecated and will be removed. Use Exec/Eval/RunSimpleString instead." ) ]
624- public static PyObject RunString ( string code , IntPtr ? globals = null , IntPtr ? locals = null )
620+ public static PyObject RunString ( string code , PyDict ? globals = null , PyObject ? locals = null )
625621 {
626- return RunString ( code , new BorrowedReference ( globals . GetValueOrDefault ( ) ) , new BorrowedReference ( locals . GetValueOrDefault ( ) ) , RunFlagType . File ) ;
622+ return RunString ( code , globals . BorrowNullable ( ) , locals . BorrowNullable ( ) , RunFlagType . File ) ;
627623 }
628624
629625 /// <summary>
0 commit comments