Terry J. Reedy <tjre...@udel.edu> added the comment:
TemporaryFile() returns an instance of _TemporaryFileWrapper. isinstance(TemporaryFile(), io.IOBase) is a sensible thing to do and would be True if _TemporaryFileWrapper subclassed the appropriate io base file. The base class for IDLE's stdxxx pseudofiles does this and hence, for instance, >>> sys.stdout <idlelib.run.StdOutputFile object at 0x0000023BEB515F70> >>> isinstance(sys.stdout, io.IOBase) True I believe that tempfile long predates io, added in 2.6. Since the IO base classes are not 'abstract base classes' in the sense of subclassing abc.ABCMeta, the tempfile classes cannot just be registered as implementing them. And tempfile has never been re-written to be based on io, by subclassing io base classes. Doing so would fix this issue. It *might* result in simpler tempfile code (but I would not be sure until it is done). It would also address (but not automatically fix) #26175. I think SpooledTemporaryFile would likely be the hardest. Martin and Serhiy are correct that a change would be an enhancement, not a bugfix. ---------- stage: -> test needed title: temp file isn't IOBase -> Make tempfiles subclass IOBase type: behavior -> enhancement versions: -Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33762> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com