Skip to content

object.__getattribute__ does not set name and obj of AttributeError #96352

Description

@philg314

Bug report

object.__getattribute__ does not set name and obj of AttributeError:

class Test: pass
test = Test()

try:
    print("test.a")
    test.a
except AttributeError as e:
    print(f"{e=}")
    print(f"{e.name=}")
    print(f"{e.obj=}")

print()

try:
    print('object.__getattribute__(test, "a")')
    object.__getattribute__(test, "a")
except AttributeError as e:
    print(f"{e=}")
    print(f"{e.name=}")
    print(f"{e.obj=}")

Output:

test.a
e=AttributeError("'Test' object has no attribute 'a'")
e.name='a'
e.obj=<__main__.Test object at 0x7f2fc87a8760>

object.__getattribute__(test, "a")
e=AttributeError("'Test' object has no attribute 'a'")
e.name=None
e.obj=None
  • CPython versions tested on: Python 3.10.5, Python 3.12.0a0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions