[issue33762] temp file isn't IOBase

2019-12-10 Thread Serhiy Storchaka


Serhiy Storchaka  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2019-12-10 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Agree, aiohttp can be fixed easily.

If somebody wants to make a pull request -- you are welcome!
https://github.com/aio-libs/aiohttp/issues/4432

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2019-12-10 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions: +Python 3.7, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2019-12-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Even if make TemporaryFile a subclass of IOBase (I am not sure we should do 
this) you could only use this in Python 3.9 and newer. I think it is better to 
fix this issue on the aiohttp side. aiohttp already registers payload types for 
a bunch of file-like types. You can also register it yourself:

aiohttp.payload.PAYLOAD_REGISTRY.register(aiohttp.payload.IOBasePayload, 
tempfile.TemporaryFile)

Seems IOBasePayload needs only read() and close() methods.

--
nosy: +asvetlov, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2019-12-10 Thread Sergii Tkachenko


Sergii Tkachenko  added the comment:

Affected as well:
Python 3.8.0 (default, Nov  3 2019, 10:55:54)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin

--
versions: +Python 3.8 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2019-12-10 Thread Sergii Tkachenko


Sergii Tkachenko  added the comment:

Confirming this to be a thing on Python 3.7.5 / OS X 10.15.1.

In [31]: f = tempfile.NamedTemporaryFile()
In [32]: isinstance(f, io.IOBase)
Out[32]: False

--
nosy: +sergiitk
versions: +Python 3.7 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2019-06-04 Thread Greg Lindahl


Greg Lindahl  added the comment:

This is breaking aiohttp client file multipart uploads from temporary files. 
I'd be willing to bet that a lot of libraries do isinstance(foo, io.IOBase) 
deep in their guts.

--
nosy: +wumpus

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2018-06-09 Thread Martin Panter


Martin Panter  added the comment:

I think it is an implementation detail whether the result subclasses IOBase or 
just implements its API. Why do you want to check the base class, and why 
IOBase in particular, rather than BufferedIOBase, RawIOBase, or TextIOBase?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2018-06-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Martin, I added you because this Tempfile issue is related to #26175.

--
nosy: +martin.panter, terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33762] temp file isn't IOBase

2018-06-03 Thread Dutcho


New submission from Dutcho :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com