1+ using System . Runtime . CompilerServices ;
2+ using System . Runtime . Loader ;
13using System ;
24using System . Collections . Generic ;
35using System . IO ;
46using System . Linq ;
57using System . Reflection ;
68using System . Runtime . InteropServices ;
9+ using Python . Runtime . Native ;
710
811namespace Python . Runtime
912{
@@ -254,10 +257,17 @@ static void OnDomainUnload(object _, EventArgs __)
254257 /// CPython interpreter process - this bootstraps the managed runtime
255258 /// when it is imported by the CLR extension module.
256259 /// </summary>
257- public static int InternalInitialize ( int size , IntPtr data )
260+ public static int InternalInitialize ( IntPtr data , int size )
258261 {
262+
263+
259264 try
260265 {
266+ // Console.WriteLine("Before Initialize");
267+ // Console.Out.Flush();
268+
269+ // Python.Runtime.Platform.InternalLoadContext.Instance.EnterContextualReflection();
270+
261271 Initialize ( setSysArgv : false ) ;
262272
263273 // Trickery - when the import hook is installed into an already
@@ -277,6 +287,9 @@ public static int InternalInitialize(int size, IntPtr data)
277287 // still doesn't work if you use the interactive interpreter,
278288 // since there is no line info to get the import line ;(
279289
290+ // Console.WriteLine("Initialized");
291+ // Console.Out.Flush();
292+
280293 string code =
281294 "import traceback\n " +
282295 "for item in traceback.extract_stack():\n " +
@@ -290,13 +303,23 @@ public static int InternalInitialize(int size, IntPtr data)
290303 " break\n " ;
291304
292305 PythonEngine . Exec ( code ) ;
306+
307+ // Console.WriteLine("Exec'd traceback hack");
308+ // Console.Out.Flush();
309+
293310 return 0 ;
294311 }
295312 catch ( PythonException e )
296313 {
297314 e . Restore ( ) ;
298315 return - 1 ;
299316 }
317+ catch ( Exception e )
318+ {
319+ // Console.Error.WriteLine(e.ToString());
320+ // Console.Error.Write(e.StackTrace);
321+ return - 2 ;
322+ }
300323 }
301324
302325 /// <summary>
0 commit comments