[New-bugs-announce] [issue33762] temp file isn't IOBase

Dutcho report at bugs.python.org
Sun Jun 3 16:53:05 EDT 2018


New submission from Dutcho <dutcho at ziggo.nl>:

I'd expect isinstance(tempfile.TemporaryFile(), io.IOBase) to be True as you can read() from and write() to the temp file.

However, on Python 3.6.5 64 bit on Windows 7 above isinstance() == False and and type(tempfile.TemporaryFile()) == tempfile._TemporaryFileWrapper, which has no super class (other than object).
Whereas, on Python 3.6.1 on iOS 11.4 (Pythonista 3.2) above isinstance() == True and type(tempfile.TemporaryFile()) == io.BufferedRandom, which has io.IOBase as its (indirect) super class.
The difference is likely caused by tempfile line 565 that equals TemporaryFile = NamedTemporaryFile in case of Windows.

This may be somewhat related to issue 26175, but isn't a duplicate as 26175 is on a temp file's attributes, and this issue is on its type

----------
components: Library (Lib)
messages: 318585
nosy: Dutcho
priority: normal
severity: normal
status: open
title: temp file isn't IOBase
type: behavior
versions: Python 3.6

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


More information about the New-bugs-announce mailing list