File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,25 @@ public PythonException() : base()
3535 if ( ( _pyType != IntPtr . Zero ) && ( _pyValue != IntPtr . Zero ) )
3636 {
3737 string type ;
38+ string message ;
39+ Runtime . Incref ( _pyType ) ;
3840 using ( PyObject pyType = new PyObject ( _pyType ) )
3941 using ( PyObject pyTypeName = pyType . GetAttr ( "__name__" ) )
4042 {
4143 type = pyTypeName . ToString ( ) ;
4244 }
43- string message = Runtime . GetManagedString ( _pyValue ) ;
45+
46+ Runtime . Incref ( _pyValue ) ;
47+ using ( PyObject pyValue = new PyObject ( _pyValue ) )
48+ {
49+ message = pyValue . ToString ( ) ;
50+ }
4451 _message = type + " : " + message ;
4552 }
4653 if ( _pyTB != IntPtr . Zero )
4754 {
4855 PyObject tb_module = PythonEngine . ImportModule ( "traceback" ) ;
56+ Runtime . Incref ( _pyTB ) ;
4957 using ( PyObject pyTB = new PyObject ( _pyTB ) ) {
5058 _tb = tb_module . InvokeMethod ( "format_tb" , pyTB ) . ToString ( ) ;
5159 }
@@ -99,6 +107,18 @@ public IntPtr PyValue
99107 get { return _pyValue ; }
100108 }
101109
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+
102122 /// <summary>
103123 /// Message Property
104124 /// </summary>
You can’t perform that action at this time.
0 commit comments