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

Skip to content

Commit 0a88f27

Browse files
committed
Use PythonException.Restore
1 parent 0ccc443 commit 0a88f27

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/runtime/importhook.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
293293
}
294294
// Save the exception
295295
var originalException = new PythonException();
296-
var originalExceptionMessage = originalException.ToString();
297296
// Otherwise, just clear the it.
298297
Exceptions.Clear();
299298

@@ -345,7 +344,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
345344
ManagedType mt = tail.GetAttribute(name, true);
346345
if (!(mt is ModuleObject))
347346
{
348-
Exceptions.SetError(Exceptions.ImportError, originalExceptionMessage);
347+
originalException.Restore();
349348
return IntPtr.Zero;
350349
}
351350
if (head == null)

0 commit comments

Comments
 (0)