[Python-checkins] python/dist/src/Lib urllib2.py,1.30,1.31
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Mon, 03 Jun 2002 09:53:03 -0700
- Previous message: [Python-checkins] python/dist/src/Lib ConfigParser.py,1.43,1.44 StringIO.py,1.26,1.27 formatter.py,1.21,1.22 hmac.py,1.6,1.7 markupbase.py,1.5,1.6 nntplib.py,1.29,1.30 popen2.py,1.24,1.25 pyclbr.py,1.25,1.26 rlcompleter.py,1.12,1.13 smtplib.py,1.57,1.58 string.py,1.63,1.64 urllib.py,1.146,1.147 urllib2.py,1.29,1.30 warnings.py,1.15,1.16 zipfile.py,1.23,1.24
- Next message: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.88,1.89
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv26841
Modified Files:
urllib2.py
Log Message:
Fix HTTPError __init__ for cases where fp is None.
The HTTPError class tries to act as a regular response objects for
HTTP protocol errors that include full responses. If the failure is
more basic, like no valid response, the __init__ choked when it tried
to initialize its superclasses in addinfourl hierarchy that requires a
valid response.
The solution isn't elegant but seems to be effective. Do not
initialize the base classes if there isn't a file object containing
the response. In this case, user code expecting to use the addinfourl
methods will fail; but it was going to fail anyway.
It might be cleaner to factor out HTTPError into two classes, only one
of which inherits from addinfourl. Not sure that the extra complexity
would lead to any improved functionality, though.
Partial fix for SF bug # 563665.
Bug fix candidate for 2.1 and 2.2.
Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** urllib2.py 3 Jun 2002 15:58:32 -0000 1.30
--- urllib2.py 3 Jun 2002 16:53:00 -0000 1.31
***************
*** 158,168 ****
def __init__(self, url, code, msg, hdrs, fp):
- self.__super_init(fp, hdrs, url)
self.code = code
self.msg = msg
self.hdrs = hdrs
self.fp = fp
- # XXX
self.filename = url
def __str__(self):
--- 158,172 ----
def __init__(self, url, code, msg, hdrs, fp):
self.code = code
self.msg = msg
self.hdrs = hdrs
self.fp = fp
self.filename = url
+ # The addinfourl classes depend on fp being a valid file
+ # object. In some cases, the HTTPError may not have a valid
+ # file object. If this happens, the simplest workaround is to
+ # not initialize the base classes.
+ if fp is not None:
+ self.__super_init(fp, hdrs, url)
def __str__(self):
- Previous message: [Python-checkins] python/dist/src/Lib ConfigParser.py,1.43,1.44 StringIO.py,1.26,1.27 formatter.py,1.21,1.22 hmac.py,1.6,1.7 markupbase.py,1.5,1.6 nntplib.py,1.29,1.30 popen2.py,1.24,1.25 pyclbr.py,1.25,1.26 rlcompleter.py,1.12,1.13 smtplib.py,1.57,1.58 string.py,1.63,1.64 urllib.py,1.146,1.147 urllib2.py,1.29,1.30 warnings.py,1.15,1.16 zipfile.py,1.23,1.24
- Next message: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.88,1.89
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]