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.

classification
Title: urllib.urlopen() raises AttributeError
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, sonderblade
Priority: normal Keywords:

Created on 2007-03-13 23:09 by sonderblade, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test-urllib-tc-attr-err.patch sonderblade, 2007-03-13 23:13
Messages (3)
msg31514 - (view) Author: Björn Lindqvist (sonderblade) Date: 2007-03-13 23:09
When you connect urlopen() to a socket that does not send any data, it produces an AttributeError. 

File "/lib/python2.6/urllib.py", line 608, in http_error_default
    return addinfourl(fp, headers, "http:" + url)
  File "/lib/python2.6/urllib.py", line 951, in __init__
    addbase.__init__(self, fp)
  File "/lib/python2.6/urllib.py", line 898, in __init__
    self.read = self.fp.read
AttributeError: 'NoneType' object has no attribute 'read'

Raising an exception is OK (I think?), but it should be an IOError instead of an AttributeError. See the attached patch for a test case for the bug.
msg31515 - (view) Author: Björn Lindqvist (sonderblade) Date: 2007-03-13 23:13
File Added: test-urllib-tc-attr-err.patch
msg31516 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-14 08:28
Committed fix and your test case in rev. 54376, 54377 (2.5).
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44712
2007-03-13 23:09:57sonderbladecreate