[issue33762] temp file isn't IOBase

Serhiy Storchaka report at bugs.python.org
Tue Dec 10 15:05:51 EST 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Actually things are more complex. TemporaryFile is not a class, it is a function, so it does not make sense to use it with isinstance(). And if add support for TemporaryFile, NamedTemporaryFile and SpooledTemporaryFile should be supported too.

It may be easier to use a virtual subclassing: register IOBasePayload with a class which has an __instancecheck__() method which checks the existence of attributes "read" and "close".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33762>
_______________________________________


More information about the Python-bugs-list mailing list