This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Talha Ahmed
Recipients Talha Ahmed
Date 2019-08-23.07:51:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566546715.82.0.869555987333.issue37927@roundup.psfhosted.org>
In-reply-to
Content
I have been experimenting a little with the `abc` module in python. A la

    >>> import abc

In the normal case you expect your ABC class to not be instantiated if it contains an unimplemented `abstractmethod`. You know like as follows:

    >>> class MyClass(metaclass=abc.ABCMeta):
    ...     @abc.abstractmethod
    ...     def mymethod(self):
    ...         return -1
    ...
    >>> MyClass()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: Can't instantiate abstract class MyClass with abstract methods mymethod

OR for any derived Class. It all seems to work fine until you inherit from something ... say `dict` or `list` as in the following: 

    >>> class YourClass(list, metaclass=abc.ABCMeta):
    ...     @abc.abstractmethod
    ...     def yourmethod(self):
    ...         return -1
    ...
    >>> YourClass()
    []

This is inconsistent because `type` is supposed to be the primary factory.

    >>> type(abc.ABCMeta)
    <class 'type'>
    >>> type(list)
    <class 'type'>

Why is the check for `__abstractmethods__` only implemented for `object_new` and not for other built-in types?
History
Date User Action Args
2019-08-23 07:51:55Talha Ahmedsetrecipients: + Talha Ahmed
2019-08-23 07:51:55Talha Ahmedsetmessageid: <1566546715.82.0.869555987333.issue37927@roundup.psfhosted.org>
2019-08-23 07:51:55Talha Ahmedlinkissue37927 messages
2019-08-23 07:51:55Talha Ahmedcreate