Content-Length: 281386 | pFad | https://github.com/python/cpython/issues/96352

8B `object.__getattribute__` does not set `name` and `obj` of `AttributeError` · Issue #96352 · python/cpython · GitHub
Skip to content

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

@philg314

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/96352

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy