Skip to content

Commit cb5ae96

Browse files
committed
Add an explanatory comment and make function prelude nicer
1 parent b9b8d7d commit cb5ae96

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Objects/exceptions.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2708,7 +2708,14 @@ static PyObject *
27082708
AttributeError_str(PyObject *op)
27092709
{
27102710
PyAttributeErrorObject *self = PyAttributeErrorObject_CAST(op);
2711-
PyObject *arg, *obj = NULL, *name;
2711+
PyObject *arg; // borrowed ref
2712+
PyObject *obj = NULL, *name = NULL;
2713+
2714+
/* .name and .obj are set automatically when attribute lookup fails, so
2715+
synthesize a more informative message from them when the caller
2716+
didn't supply a meaningful one of their own -- that is, when args is
2717+
empty, or contains only the attribute name. Otherwise, use the
2718+
message the caller gave. */
27122719

27132720
Py_BEGIN_CRITICAL_SECTION(self);
27142721
if (

0 commit comments

Comments
 (0)