Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31236b5

Browse files
committed
ImportHook preserves the original exception message when an import fails
1 parentfc47172 commit31236b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎src/runtime/importhook.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
291291
// We don't support them anyway
292292
returnIntPtr.Zero;
293293
}
294+
// Save the exception
295+
varoriginalException=newPythonException();
296+
varoriginalExceptionMessage=originalException.ToString();
294297
// Otherwise, just clear the it.
295298
Exceptions.Clear();
296299

@@ -342,7 +345,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
342345
ManagedTypemt=tail.GetAttribute(name,true);
343346
if(!(mtisModuleObject))
344347
{
345-
Exceptions.SetError(Exceptions.ImportError,$"No module named{name}");
348+
Exceptions.SetError(Exceptions.ImportError,originalExceptionMessage);
346349
returnIntPtr.Zero;
347350
}
348351
if(head==null)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp