Skip to content

Make the slotted missing attribute AttributeError's message the same as the slotless one #92355

Closed
@Gouvernathor

Description

@Gouvernathor

Feature or enhancement

Make both AttributeErrors the same.
I'm not 100% sure whether this is a bug report or a feature request.

Pitch

For the next example classes, the behavior of X().slot is slightly different :

class A:
    pass

class B:
    __slots__ = "slot"

class C:
    __slots__ = ()

A().slot and C().slot will raise AttributeError: 'A' object has no attribute 'slot'.
However, B().slot will raise AttributeError: slot.
The supplementary information (although limited) from the first message should be included in the second one as well. And I think it's a mistake to make a slotted missing attribute and an unslotted one behave differently, for arguable visibility reasons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions