Closed
Description
Environment
- Pythonnet version: V2.5.1.
- Python version: V3.8.4 64 bit
- Operating System: Windows 10 64 bit
Details
- Run the following code in a console application with Visual Studio.
using (Py.GIL())
{
var script = "a=b\n";
try
{
PythonEngine.Exec(script);
}
catch (PythonException ex)
{
try
{
var m = ex.Format();
}
catch (Exception exception)
{
var t = exception.GetType();
var s = exception.Message;
}
}
}
Since "a=b" is invalid, I expected an error message like so returned by ex.Format()
:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'b' is not defined
However, Format() throws another PythonException - "AttributeError : 'str' object has no attribute 'cause'" with the following stack trace - list(TracebackException(\n', ' File "C:\Python38\Lib\traceback.py", line 479, in init\n if (exc_value and exc_value.cause is not None\n'] .
Metadata
Metadata
Assignees
Labels
No labels