- Notifications
You must be signed in to change notification settings - Fork749
Closed
Description
Environment
- Pythonnet version: 3.0.0 preview
- Python version: 3.8 win32
- Operating System: Windows
- .NET Runtime: .NET 5
Summary
If there is a callback from .NET to Python, and the Python code raises a .NET type exception, instead of the corresponding real .NET exception was rethrown on the .NET side (after marshalling), alwaysPython.Runtime.PythonException
is thrown.
Details
.NET snippet
classFoo{publicstaticvoidBar(Actionaction){try{action.Invoke();Console.WriteLine("No exception.");}catch(NullReferenceException){Console.WriteLine("Null reference caught.");}catch(Exceptionex){Console.WriteLine("General exception caught: "+ex.GetType().Type);}}}
Python snippet
# .NET importsfromSystemimportNullReferenceException,ActionfromMyProgramimportFoo# Preparationdefcall():raiseNullReferenceException()action=Action(call)# ActionFoo.Bar(action)
Expected output:Null reference caught.
Actual output:General exception caught: Python.Runtime.PythonException
Metadata
Metadata
Assignees
Labels
No labels