Author mdehoon
Recipients mdehoon
Date 2012-12-19.06:42:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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 = ""
handle = urllib.request.urlopen(url)
wrapped_handle = io.TextIOWrapper(handle, encoding='utf-8')
for line in wrapped_handle:

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 website.
Date User Action Args
2012-12-19 06:42:14mdehoonsetrecipients: + mdehoon
2012-12-19 06:42:14mdehoonsetmessageid: <>
2012-12-19 06:42:14mdehoonlinkissue16723 messages
2012-12-19 06:42:12mdehooncreate