--- a/mercurial/statichttprepo.py Mon Jul 25 15:45:11 2011 -0500
+++ b/mercurial/statichttprepo.py Mon Jul 25 15:47:43 2011 -0500
@@ -31,15 +31,11 @@
try:
f = self.opener.open(req)
data = f.read()
- if hasattr(f, 'getcode'):
- # python 2.6+
- code = f.getcode()
- elif hasattr(f, 'code'):
- # undocumented attribute, seems to be set in 2.4 and 2.5
- code = f.code
- else:
- # Don't know how to check, hope for the best.
- code = 206
+ # Python 2.6+ defines a getcode() function, and 2.4 and
+ # 2.5 appear to always have an undocumented code attribute
+ # set. If we can't read either of those, fall back to 206
+ # and hope for the best.
+ code = getattr(f, 'getcode', lambda : getattr(f, 'code', 206))()
except urllib2.HTTPError, inst:
num = inst.code == 404 and errno.ENOENT or None
raise IOError(num, inst)