[ python-Bugs-1429783 ] urllib.py: AttributeError on BadStatusLine

SourceForge.net noreply at sourceforge.net
Sat Feb 11 19:15:44 CET 2006


Bugs item #1429783, was opened at 2006-02-11 19:15
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1429783&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Robert Kiendl (kxroberto)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib.py: AttributeError on BadStatusLine

Initial Comment:
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.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1429783&group_id=5470


More information about the Python-bugs-list mailing list