This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients
Date 2006-11-09.21:04:07
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I set up a simple server that returns an empty response.  

>>> from socket import *
>>> s = socket()
>>> s.bind(("", 9999))
>>> while 1: x, c = s.accept(); print c; x.recv(1000);
x.close()
...


Pointing urllib at this gives a traceback:

Python 2.6a0 (trunk:52099M, Oct  3 2006, 09:59:17) 
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import urllib
>>> urllib.urlopen('http://localhost:9999/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/guido/p/Lib/urllib.py", line 82, in urlopen
    return opener.open(url)
  File "/home/guido/p/Lib/urllib.py", line 190, in open
    return getattr(self, name)(url)
  File "/home/guido/p/Lib/urllib.py", line 334, in
open_http
    return self.http_error(url, fp, errcode, errmsg,
headers)
  File "/home/guido/p/Lib/urllib.py", line 351, in
http_error
    return self.http_error_default(url, fp, errcode,
errmsg, headers)
  File "/home/guido/p/Lib/urllib.py", line 608, in
http_error_default
    return addinfourl(fp, headers, "http:" + url)
  File "/home/guido/p/Lib/urllib.py", line 951, in __init__
    addbase.__init__(self, fp)
  File "/home/guido/p/Lib/urllib.py", line 898, in __init__
    self.read = self.fp.read
AttributeError: 'NoneType' object has no attribute 'read'
>>> 

I can repeat this with 2.2.3 and 2.4.3 as well (don't
have 2.3 around for testing).

The direct cause of the problem is that h.getfile() on
line 329 of urllib.py (in head of trunk) returns None.
History
Date User Action Args
2007-08-23 14:49:37adminlinkissue1593751 messages
2007-08-23 14:49:37admincreate