File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2706,23 +2706,29 @@ static PyObject *
27062706AttributeError_str (PyObject * op )
27072707{
27082708 PyAttributeErrorObject * self = PyAttributeErrorObject_CAST (op );
2709- PyObject * ret = NULL , * arg ;
2709+ PyObject * arg , * obj = NULL , * name ;
2710+
27102711 Py_BEGIN_CRITICAL_SECTION (self );
2711- if (
2712- self -> obj && self -> name && PyUnicode_Check (self -> name )
2712+ if (self -> obj && self -> name && PyUnicode_Check (self -> name )
27132713 && ((PyTuple_GET_SIZE (self -> args ) == 1
27142714 && PyUnicode_Check (arg = PyTuple_GET_ITEM (self -> args , 0 ))
27152715 && PyUnicode_Equal (arg , self -> name ))
2716- || PyTuple_GET_SIZE (self -> args ) == 0 )
2717- ) {
2718- ret = PyUnicode_FromFormat ( "%R has no attribute '%U'" ,
2719- self -> obj , self -> name );
2716+ || PyTuple_GET_SIZE (self -> args ) == 0 ))
2717+ {
2718+ obj = Py_NewRef ( self -> obj );
2719+ name = Py_NewRef ( self -> name );
27202720 }
27212721 Py_END_CRITICAL_SECTION ();
2722- if (!ret ) {
2723- ret = BaseException_str (op );
2722+
2723+ if (!obj ) {
2724+ return BaseException_str (op );
27242725 }
2725- return ret ;
2726+
2727+ PyObject * result = PyUnicode_FromFormat ("%R has no attribute '%U'" ,
2728+ obj , name );
2729+ Py_DECREF (obj );
2730+ Py_DECREF (name );
2731+ return result ;
27262732}
27272733
27282734static int
You can’t perform that action at this time.
0 commit comments