@@ -55,51 +55,12 @@ internal static Exception ToException(IntPtr ob)
5555 {
5656 message = e . Message ;
5757 }
58- if ( ( e . StackTrace != null ) && ( e . StackTrace != String . Empty ) )
58+ if ( ! string . IsNullOrEmpty ( e . StackTrace ) )
5959 {
6060 message = message + "\n " + e . StackTrace ;
6161 }
6262 return Runtime . PyUnicode_FromString ( message ) ;
6363 }
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- }
10364 }
10465
10566 /// <summary>
@@ -190,10 +151,10 @@ internal static void SetArgs(IntPtr ob)
190151 return ;
191152
192153 IntPtr args ;
193- if ( e . Message != String . Empty )
154+ if ( ! string . IsNullOrEmpty ( e . Message ) )
194155 {
195156 args = Runtime . PyTuple_New ( 1 ) ;
196- IntPtr msg = Runtime . PyUnicode_FromString ( e . Message ) ;
157+ var msg = Runtime . PyUnicode_FromString ( e . Message ) ;
197158 Runtime . PyTuple_SetItem ( args , 0 , msg ) ;
198159 }
199160 else
0 commit comments