New submission from Michiel de Hoon:

I am trying to use io.TextIOWrapper to wrap a handle returned by 
urllib.request.urlopen. Reading line-by-line from the wrapped handle terminates 
prematurely.

As an example, consider this script:

import urllib.request
import io

url = "http://www.python.org";
handle = urllib.request.urlopen(url)
wrapped_handle = io.TextIOWrapper(handle, encoding='utf-8')
for line in wrapped_handle:
    pass

This gives:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file.

This happens after 335 out of the 430 lines have been read (the last line read 
is "<p>The <a class="reference external" href="/psf/">Python Software 
Foundation</a> holds the intellectual property\n", which is line 335 on the 
www.python.org website.

----------
messages: 177726
nosy: mdehoon
priority: normal
severity: normal
status: open
title: io.TextIOWrapper on urllib.request.urlopen terminates prematurely
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16723>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to