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: AttributeError exception in urllib.urlopen
Type: crash Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, sprigogin
Priority: normal Keywords:

Created on 2009-05-07 02:12 by sprigogin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg87356 - (view) Author: Sergey Prigogin (sprigogin) Date: 2009-05-07 02:12
File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 82, in
urlopen
   return opener.open(url)
  File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 190, in open
   return getattr(self, name)(url)
  File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 322, in
open_http
   return self.http_error(url, fp, errcode, errmsg, headers)
  File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 339, in
http_error
   return self.http_error_default(url, fp, errcode, errmsg, headers)
  File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 579, in
http_error_default
   return addinfourl(fp, headers, "http:" + url)
  File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 871, in
__init__
   addbase.__init__(self, fp)
  File "/usr/grte/v1/piii-linux/lib/python2.4/urllib.py", line 818, in
__init__
   self.read = self.fp.read
 AttributeError: 'NoneType' object has no attribute 'read'
msg87364 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-05-07 09:35
Sorry, we need more information to diagnose the problem.
What did you try? Can you provide a minimal example?

Does this reproduce with newer python versions? 2.4 is quite an old
version and will not be corrected.
msg87383 - (view) Author: Sergey Prigogin (sprigogin) Date: 2009-05-07 18:09
The problem is pretty obvious from the code.

URLopener.open_http contains the following code:

        if data is not None:
            h.send(data)
        errcode, errmsg, headers = h.getreply()
        fp = h.getfile()
        if errcode == 200:
            return addinfourl(fp, headers, "http:" + url)
        else:
            if data is None:
                return self.http_error(url, fp, errcode, errmsg, headers)
            else:
                return self.http_error(url, fp, errcode, errmsg,
headers, data)

In case of an error h.getfile() may return None. self.http_error (line
322) is called with None fp. http_error calls self.http_error_default
(line 339). FancyURLopener.http_error_default calls addinfourl(fp,
headers, "http:" + url) (line 579), which expects fp to be not None.

For variety of reasons I cannot run this test case with a newer Python
version.
msg87407 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-05-07 20:34
Thanks for the info.
This problem is a duplicate of issue767111, which was corrected two 
years ago.
I suggest you to upgrade to 2.5 at least.
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50202
2009-05-07 20:34:57amaury.forgeotdarcsetstatus: open -> closed
resolution: out of date
messages: + msg87407
2009-05-07 18:09:00sprigoginsetmessages: + msg87383
2009-05-07 09:35:06amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg87364
2009-05-07 02:12:39sprigogincreate