##// END OF EJS Templates
statichttprepo: replace hasattr with getattr
Augie Fackler -
r14962:1c917bc6 default
parent child Browse files
Show More
@@ -31,15 +31,11 b' class httprangereader(object):'
31 try:
31 try:
32 f = self.opener.open(req)
32 f = self.opener.open(req)
33 data = f.read()
33 data = f.read()
34 if hasattr(f, 'getcode'):
34 # Python 2.6+ defines a getcode() function, and 2.4 and
35 # python 2.6+
35 # 2.5 appear to always have an undocumented code attribute
36 code = f.getcode()
36 # set. If we can't read either of those, fall back to 206
37 elif hasattr(f, 'code'):
37 # and hope for the best.
38 # undocumented attribute, seems to be set in 2.4 and 2.5
38 code = getattr(f, 'getcode', lambda : getattr(f, 'code', 206))()
39 code = f.code
40 else:
41 # Don't know how to check, hope for the best.
42 code = 206
43 except urllib2.HTTPError, inst:
39 except urllib2.HTTPError, inst:
44 num = inst.code == 404 and errno.ENOENT or None
40 num = inst.code == 404 and errno.ENOENT or None
45 raise IOError(num, inst)
41 raise IOError(num, inst)
General Comments 0
You need to be logged in to leave comments. Login now