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.py: AttributeError on BadStatusLine
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, kxroberto, nnorwitz
Priority: normal Keywords:

Created on 2006-02-11 18:15 by kxroberto, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg27494 - (view) Author: kxroberto (kxroberto) Date: 2006-02-11 18:15
PythonWin 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC
v.1200 32 bit (Intel)] on win32.


in httplib errcode -1 &
file=self._conn.sock.makefile('rb', 0) is returned on
Badstatusline:

        except BadStatusLine, e:
            ### hmm. if getresponse() ever closes the
socket on a bad request,
            ### then we are going to have problems with
self.sock

            ### should we keep this behavior? do people
use it?
            # keep the socket open (as a file), and
return it
            self.file = self._conn.sock.makefile('rb', 0)

            # close our socket -- we want to restart
after any protocol error
            self.close()

            self.headers = None
            return -1, e.line, None



fp = h.getfile()

delivers None in urllib.URLopener.open_http

and this is traceback leading to an AttributeError 


Traceback (most recent call last):

  File "<interactive input>", line 1, in ?
  File "C:\Python23\lib\urllib.py", line 181, in open
    return getattr(self, name)(url)
  File "C:\Python23\lib\urllib.py", line 306, in open_http
    return self.http_error(url, fp, errcode, errmsg,
headers)
  File "C:\Python23\lib\urllib.py", line 319, in http_error
    result = method(url, fp, errcode, errmsg, headers)
  File "C:\Python23\lib\urllib.py", line 584, in
http_error_301
    return self.http_error_302(url, fp, errcode,
errmsg, headers, data)
  File "C:\Python23\lib\urllib.py", line 565, in
http_error_302
    data)
  File "C:\Python23\lib\urllib.py", line 580, in
redirect_internal
    return self.open(newurl)
  File "C:\Python23\lib\urllib.py", line 181, in open
    return getattr(self, name)(url)
  File "C:\Python23\lib\urllib.py", line 306, in open_http
    return self.http_error(url, fp, errcode, errmsg,
headers)
  File "C:\Python23\lib\urllib.py", line 323, in http_error
    return self.http_error_default(url, fp, errcode,
errmsg, headers)
  File "C:\Python23\lib\urllib.py", line 327, in
http_error_default
    void = fp.read()
AttributeError: 'NoneType' object has no attribute 'read'



As I get this error rarely I cannot reproduce exactly how

self._conn.sock.makefile('rb', 0)

delivers None in that case.

msg27495 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-02-12 06:55
Logged In: YES 
user_id=33168

This may be a duplicate of a bug submitted by Bram Cohen. 
It was a couple of years ago and I don't remember any other
details.
msg27496 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-02-12 06:56
Logged In: YES 
user_id=33168

I should add that the other bug is still open.
msg27497 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-14 08:29
Fixed that bug finally in rev. 54376, 54377 (2.5).
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42892
2006-02-11 18:15:44kxrobertocreate