@@ -55,51 +55,12 @@ internal static Exception ToException(IntPtr ob)
55
55
{
56
56
message = e . Message ;
57
57
}
58
- if ( ( e . StackTrace != null ) && ( e . StackTrace != String . Empty ) )
58
+ if ( ! string . IsNullOrEmpty ( e . StackTrace ) )
59
59
{
60
60
message = message + "\n " + e . StackTrace ;
61
61
}
62
62
return Runtime . PyUnicode_FromString ( message ) ;
63
63
}
64
-
65
- //====================================================================
66
- // Exceptions __getattribute__ implementation.
67
- // handles Python's args and message attributes
68
- //====================================================================
69
-
70
- public static IntPtr tp_getattro ( IntPtr ob , IntPtr key )
71
- {
72
- if ( ! Runtime . PyString_Check ( key ) )
73
- {
74
- Exceptions . SetError ( Exceptions . TypeError , "string expected" ) ;
75
- return IntPtr . Zero ;
76
- }
77
-
78
- string name = Runtime . GetManagedString ( key ) ;
79
- if ( name == "args" )
80
- {
81
- Exception e = ToException ( ob ) ;
82
- IntPtr args ;
83
- if ( e . Message != String . Empty )
84
- {
85
- args = Runtime . PyTuple_New ( 1 ) ;
86
- IntPtr msg = Runtime . PyUnicode_FromString ( e . Message ) ;
87
- Runtime . PyTuple_SetItem ( args , 0 , msg ) ;
88
- }
89
- else
90
- {
91
- args = Runtime . PyTuple_New ( 0 ) ;
92
- }
93
- return args ;
94
- }
95
-
96
- if ( name == "message" )
97
- {
98
- return ExceptionClassObject . tp_str ( ob ) ;
99
- }
100
-
101
- return Runtime . PyObject_GenericGetAttr ( ob , key ) ;
102
- }
103
64
}
104
65
105
66
/// <summary>
@@ -190,10 +151,10 @@ internal static void SetArgs(IntPtr ob)
190
151
return ;
191
152
192
153
IntPtr args ;
193
- if ( e . Message != String . Empty )
154
+ if ( ! string . IsNullOrEmpty ( e . Message ) )
194
155
{
195
156
args = Runtime . PyTuple_New ( 1 ) ;
196
- IntPtr msg = Runtime . PyUnicode_FromString ( e . Message ) ;
157
+ var msg = Runtime . PyUnicode_FromString ( e . Message ) ;
197
158
Runtime . PyTuple_SetItem ( args , 0 , msg ) ;
198
159
}
199
160
else
0 commit comments