Skip to content

Commit 1e88331

Browse files
committed
Simplify?
1 parent 3854563 commit 1e88331

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

Objects/exceptions.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,18 +2706,14 @@ static PyObject *
27062706
AttributeError_str(PyObject *op)
27072707
{
27082708
PyAttributeErrorObject *self = PyAttributeErrorObject_CAST(op);
2709-
if (
2710-
self->obj
2711-
&& self->name
2712-
&& (!PyTuple_GET_SIZE(self->args)
2713-
|| (PyTuple_GET_SIZE(self->args) == 1
2714-
&& PyUnicode_Equal(PyTuple_GET_ITEM(self->args, 0), self->name))
2715-
)
2716-
) {
2717-
return PyUnicode_FromFormat("%R has no attribute '%U'",
2718-
self->obj, self->name);
2709+
if (!self->obj || !self->name || PyTuple_GET_SIZE(self->args) > 1
2710+
|| (PyTuple_GET_SIZE(self->args) == 1 &&
2711+
!PyUnicode_Equal(PyTuple_GET_ITEM(self->args, 0), self->name)))
2712+
{
2713+
return BaseException_str(op);
27192714
}
2720-
return BaseException_str(op);
2715+
return PyUnicode_FromFormat("%R has no attribute '%U'",
2716+
self->obj, self->name);
27212717
}
27222718

27232719
static int

0 commit comments

Comments
 (0)