Skip to content

Commit a1587cb

Browse files
author
hardcoded
committed
Changed the PythonException.Message value so it displays the name of the exception class instead ("Exception") instead of its representation ("<type 'exceptions.Exception'>").
1 parent 2b150f1 commit a1587cb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pythonnet/src/embed_tests/pythonexception.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void TestMessage()
3333
}
3434
catch (PythonException e)
3535
{
36-
Assert.AreEqual("exceptions.IndexError : list index out of range", e.Message);
36+
Assert.AreEqual("IndexError : list index out of range", e.Message);
3737
}
3838
}
3939

pythonnet/src/runtime/pythonexception.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public PythonException() : base()
3434
IntPtr gs = PythonEngine.AcquireLock();
3535
if ((_pyType != IntPtr.Zero) && (_pyValue != IntPtr.Zero))
3636
{
37-
string type = new PyObject(_pyType).ToString();
37+
string type = new PyObject(_pyType).GetAttr("__name__").ToString();
3838
string message = Runtime.GetManagedString(_pyValue);
3939
_message = type + " : " + message;
4040
}

0 commit comments

Comments
 (0)