@@ -161,46 +161,40 @@ BaseException_traverse(PyObject *op, visitproc visit, void *arg)
161161 return 0 ;
162162}
163163
164+ /*[clinic input]
165+ @critical_section
166+ BaseException.__str__
167+ [clinic start generated code]*/
168+
164169static PyObject *
165- BaseException_str (PyObject * op )
170+ BaseException_str_impl (PyBaseExceptionObject * self )
171+ /*[clinic end generated code: output=f9cf63c6d14a73fe input=cd946062d6786776]*/
166172{
167- PyBaseExceptionObject * self = PyBaseExceptionObject_CAST (op );
168-
169- PyObject * res ;
170- Py_BEGIN_CRITICAL_SECTION (self );
171173 switch (PyTuple_GET_SIZE (self -> args )) {
172174 case 0 :
173- res = Py_GetConstant (Py_CONSTANT_EMPTY_STR );
174- break ;
175+ return Py_GetConstant (Py_CONSTANT_EMPTY_STR );
175176 case 1 :
176- res = PyObject_Str (PyTuple_GET_ITEM (self -> args , 0 ));
177- break ;
177+ return PyObject_Str (PyTuple_GET_ITEM (self -> args , 0 ));
178178 default :
179- res = PyObject_Str (self -> args );
180- break ;
179+ return PyObject_Str (self -> args );
181180 }
182- Py_END_CRITICAL_SECTION ();
183- return res ;
184181}
185182
183+ /*[clinic input]
184+ @critical_section
185+ BaseException.__repr__
186+ [clinic start generated code]*/
187+
186188static PyObject *
187- BaseException_repr (PyObject * op )
189+ BaseException_repr_impl (PyBaseExceptionObject * self )
190+ /*[clinic end generated code: output=c885549a153a6007 input=20941168ad0ab577]*/
188191{
189-
190- PyBaseExceptionObject * self = PyBaseExceptionObject_CAST (op );
191-
192- PyObject * res ;
193- Py_BEGIN_CRITICAL_SECTION (self );
194192 const char * name = _PyType_Name (Py_TYPE (self ));
195193 if (PyTuple_GET_SIZE (self -> args ) == 1 ) {
196- res = PyUnicode_FromFormat ("%s(%R)" , name ,
194+ return PyUnicode_FromFormat ("%s(%R)" , name ,
197195 PyTuple_GET_ITEM (self -> args , 0 ));
198196 }
199- else {
200- res = PyUnicode_FromFormat ("%s%R" , name , self -> args );
201- }
202- Py_END_CRITICAL_SECTION ();
203- return res ;
197+ return PyUnicode_FromFormat ("%s%R" , name , self -> args );
204198}
205199
206200/* Pickling support */
0 commit comments