X Tutup
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/runtime/pythonexception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,25 @@ public PythonException() : base()
if ((_pyType != IntPtr.Zero) && (_pyValue != IntPtr.Zero))
{
string type;
string message;
Runtime.Incref(_pyType);
using (PyObject pyType = new PyObject(_pyType))
using (PyObject pyTypeName = pyType.GetAttr("__name__"))
{
type = pyTypeName.ToString();
}
string message = Runtime.GetManagedString(_pyValue);

Runtime.Incref(_pyValue);
using (PyObject pyValue = new PyObject(_pyValue))
{
message = pyValue.ToString();
}
_message = type + " : " + message;
}
if (_pyTB != IntPtr.Zero)
{
PyObject tb_module = PythonEngine.ImportModule("traceback");
Runtime.Incref(_pyTB);
using (PyObject pyTB = new PyObject(_pyTB)) {
_tb = tb_module.InvokeMethod("format_tb", pyTB).ToString();
}
Expand Down Expand Up @@ -99,6 +107,18 @@ public IntPtr PyValue
get { return _pyValue; }
}

/// <summary>
/// PyTB Property
/// </summary>
///
/// <remarks>
/// Returns the TraceBack as a Python object.
/// </remarks>

public IntPtr PyTB {
get { return _pyTB; }
}

/// <summary>
/// Message Property
/// </summary>
Expand Down
X Tutup