File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,25 @@ public PythonException() : base()
35
35
if ( ( _pyType != IntPtr . Zero ) && ( _pyValue != IntPtr . Zero ) )
36
36
{
37
37
string type ;
38
+ string message ;
39
+ Runtime . Incref ( _pyType ) ;
38
40
using ( PyObject pyType = new PyObject ( _pyType ) )
39
41
using ( PyObject pyTypeName = pyType . GetAttr ( "__name__" ) )
40
42
{
41
43
type = pyTypeName . ToString ( ) ;
42
44
}
43
- string message = Runtime . GetManagedString ( _pyValue ) ;
45
+
46
+ Runtime . Incref ( _pyValue ) ;
47
+ using ( PyObject pyValue = new PyObject ( _pyValue ) )
48
+ {
49
+ message = pyValue . ToString ( ) ;
50
+ }
44
51
_message = type + " : " + message ;
45
52
}
46
53
if ( _pyTB != IntPtr . Zero )
47
54
{
48
55
PyObject tb_module = PythonEngine . ImportModule ( "traceback" ) ;
56
+ Runtime . Incref ( _pyTB ) ;
49
57
using ( PyObject pyTB = new PyObject ( _pyTB ) ) {
50
58
_tb = tb_module . InvokeMethod ( "format_tb" , pyTB ) . ToString ( ) ;
51
59
}
@@ -99,6 +107,18 @@ public IntPtr PyValue
99
107
get { return _pyValue ; }
100
108
}
101
109
110
+ /// <summary>
111
+ /// PyTB Property
112
+ /// </summary>
113
+ ///
114
+ /// <remarks>
115
+ /// Returns the TraceBack as a Python object.
116
+ /// </remarks>
117
+
118
+ public IntPtr PyTB {
119
+ get { return _pyTB ; }
120
+ }
121
+
102
122
/// <summary>
103
123
/// Message Property
104
124
/// </summary>
You can’t perform that action at this time.
0 commit comments