Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit df84e29

Browse files
committed
* Reset Exceptions to IntPtr.Zero
* Cleanup the code
1 parent 924b217 commit df84e29

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/runtime/exceptions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ internal static void Shutdown()
140140
foreach (FieldInfo fi in type.GetFields(BindingFlags.Public | BindingFlags.Static))
141141
{
142142
var op = (IntPtr)fi.GetValue(type);
143-
if (op != IntPtr.Zero)
143+
if (op == IntPtr.Zero)
144144
{
145-
Runtime.XDecref(op);
145+
continue;
146146
}
147+
Runtime.XDecref(op);
148+
fi.SetValue(null, IntPtr.Zero);
147149
}
148150
Runtime.Py_CLEAR(ref exceptions_module);
149151
Runtime.Py_CLEAR(ref warnings_module);

src/runtime/interop.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,9 @@ internal static ThunkInfo GetThunk(MethodInfo method, string funcType = null)
499499
{
500500
return ThunkInfo.Empty;
501501
}
502-
try
503-
{
504-
Delegate d = Delegate.CreateDelegate(dt, method);
505-
var info = new ThunkInfo(d);
506-
return info;
507-
}
508-
catch (Exception)
509-
{
510-
throw;
511-
}
502+
Delegate d = Delegate.CreateDelegate(dt, method);
503+
var info = new ThunkInfo(d);
504+
return info;
512505
}
513506

514507

src/runtime/runtime.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,7 @@ internal static void Shutdown()
358358
}
359359
#endif
360360
AssemblyManager.Shutdown();
361-
Exceptions.Shutdown();
362361
ImportHook.Shutdown();
363-
Finalizer.Shutdown();
364362

365363
#if !NETSTANDARD
366364
if (mode != ShutdownMode.Reload)
@@ -377,6 +375,9 @@ internal static void Shutdown()
377375
MetaType.Release();
378376
PyCLRMetaType = IntPtr.Zero;
379377

378+
Exceptions.Shutdown();
379+
Finalizer.Shutdown();
380+
380381
if (mode != ShutdownMode.Normal)
381382
{
382383
PyGC_Collect();

0 commit comments

Comments
 (0)