Skip to content

__abstractmethods__ gives attribute error although described in dir(type) #91591

Closed
@vainaixr

Description

@vainaixr

current scenario:
running dir on type gives this

['__abstractmethods__', '__base__', '__bases__', '__basicsize__', '__call__',
 '__class__', '__delattr__', '__dict__', '__dictoffset__', '__dir__', '__doc__',
 '__eq__', '__flags__', '__format__', '__ge__', '__getattribute__', '__gt__',
 '__hash__', '__init__', '__init_subclass__', '__instancecheck__',
 '__itemsize__', '__le__', '__lt__', '__module__', '__mro__', '__name__',
 '__ne__', '__new__', '__prepare__', '__qualname__', '__reduce__',
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
 '__subclasscheck__', '__subclasses__', '__subclasshook__',
 '__text_signature__', '__weakrefoffset__', 'mro']

but when we do,

type.__abstractmethods__

it gives,

AttributeError: __abstractmethods__

I ran type on every attribute of every builtin, (like, type(zip.__init__), type(type.__base__), type(super.__thisclass__), ...)
and this was the only one that resulted in an error.

expected scenario:

  1. either change the implementation of __abstractmethods__ to return an empty frozen set,
  2. or change dir to not return __abstractmethods__ for type.

related issue,
https://stackoverflow.com/questions/24914584/abstractmethods-and-attributeerror

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