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 Jon McMahon
Recipients Jon McMahon
Date 2019-02-10.17:37:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549820237.63.0.597110746163.issue35958@roundup.psfhosted.org>
In-reply-to
Content
Subclasses of io.IOBase can be instantiated with abstractmethod()s, even though ABCs are supposed to prevent this from happening. I'm guessing this has to do with io using the _io C module because the alternative pure-python implementation _pyio doesn't seem to have this issue. I'm using Python 3.6.7

>>> import _pyio
>>> import io
>>> import abc
>>> class TestPurePython(_pyio.IOBase):
...     @abc.abstractmethod
...     def foo(self):
...             print('Pure python implementation')
... 
>>> class TestCExtension(io.IOBase):
...     @abc.abstractmethod
...     def bar(self):
...             print('C extension implementation')
... 
>>> x=TestPurePython()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class TestPurePython with abstract methods foo
>>> y=TestCExtension()
>>> y.bar()
C extension implementation
>>>
History
Date User Action Args
2019-02-10 17:37:20Jon McMahonsetrecipients: + Jon McMahon
2019-02-10 17:37:17Jon McMahonsetmessageid: <1549820237.63.0.597110746163.issue35958@roundup.psfhosted.org>
2019-02-10 17:37:17Jon McMahonlinkissue35958 messages
2019-02-10 17:37:17Jon McMahoncreate