[issue21069] test_fileno of test_urllibnet intermittently fails when using www.example.com
Senthil Kumaran
report at bugs.python.org
Wed Apr 16 05:53:02 CEST 2014
Senthil Kumaran added the comment:
This is turning out be trickier than I ever thought.
fileno() returning b'' is just random error. The underlying issue is, *directly* reading from the fp of the socket() is returning a incomplete output at all times. The correct way to read the output is by using HTTPResponse read() method only it seems.
Here is a small snippet that will fail for every url.
from urllib.request import urlopen
import os
web = "http://www.example.org"
open_url = urlopen(web)
fd = open_url.fileno()
with os.fdopen(fd, 'rb') as f:
file_read_len = len(f.read())
req = urlopen(web)
res_len = len(req.read())
assert file_read_len == res_len
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21069>
_______________________________________
More information about the Python-bugs-list
mailing list