Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philg314 opened this issue Aug 28, 2022 · 1 comment
Closed

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

philg314 opened this issue Aug 28, 2022 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@philg314
Copy link
Contributor

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
@philg314 philg314 added the type-bug An unexpected behavior, bug, or error label Aug 28, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 8, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 8, 2022
miss-islington added a commit that referenced this issue Sep 8, 2022
miss-islington added a commit that referenced this issue Sep 8, 2022
@philg314
Copy link
Contributor Author

philg314 commented Sep 8, 2022

Fixed in #96353

@philg314 philg314 closed this as completed Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant