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,14 +2706,24 @@ static PyObject *
27062706AttributeError_str (PyObject * op )
27072707{
27082708 PyAttributeErrorObject * self = PyAttributeErrorObject_CAST (op );
2709- if (!self -> obj || !self -> name || PyTuple_GET_SIZE (self -> args ) > 1
2709+ PyObject * ret , * arg ;
2710+ Py_BEGIN_CRITICAL_SECTION (self );
2711+ if (
2712+ !self -> obj || !self -> name || !PyUnicode_Check (self -> name )
2713+ || PyTuple_GET_SIZE (self -> args ) > 1
27102714 || (PyTuple_GET_SIZE (self -> args ) == 1
2711- && !PyUnicode_Equal (PyTuple_GET_ITEM (self -> args , 0 ), self -> name )))
2712- {
2713- return BaseException_str (op );
2715+ && PyUnicode_Check (arg = PyTuple_GET_ITEM (self -> args , 0 ))
2716+ && !PyUnicode_Equal (arg , self -> name ))
2717+ ) {
2718+ ret = BaseException_str (op );
2719+ }
2720+ else {
2721+ ret = PyUnicode_FromFormat ("%R has no attribute '%U'" ,
2722+ self -> obj , self -> name );
27142723 }
2715- return PyUnicode_FromFormat ("%R has no attribute '%U'" ,
2716- self -> obj , self -> name );
2724+ Py_END_CRITICAL_SECTION ();
2725+ return ret ;
2726+
27172727}
27182728
27192729static int
You can’t perform that action at this time.
0 commit comments