[issue16723] io.TextIOWrapper on urllib.request.urlopen terminates prematurely

Amaury Forgeot d'Arc report at bugs.python.org
Wed Dec 19 10:55:14 CET 2012


Amaury Forgeot d'Arc added the comment:

Hum, io objects are not supposed to close themselves when they run out of data.
Even if HTTPResponse chooses to close the underlying socket (to clean unused resources?), it should not report itself as a closed io.IOBase.
Subsequent calls read() should return b"", this is the io.RawIOBase way to indicate EOF.

To fix this particular example, it seems enough to delete the "@property def closed(self)" from HTTPResponse. Note the XXX just above:
"""
    # XXX This class should probably be revised to act more like
    # the "raw stream" that BufferedReader expects.
"""
But close() should be modified as well, and internal calls to close() should be changed to only close the underlying socket.

----------
nosy: +amaury.forgeotdarc, pitrou

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16723>
_______________________________________


More information about the Python-bugs-list mailing list