D5715: statichttprepo: use URLError.reason directly

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Jan 26 19:43:58 UTC 2019


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  https://phab.mercurial-scm.org/rHG0b3f4be5c5bf8258e4370c7755a2a1ab32ac07eb changed str(inst) to inst.reason[0] all the way back
  in 2006. URLError.reason is a str and we should have taken that
  attribute in its entirety. I think the code was supposed to be
  inst.args[1] for compatibility with ancient Python versions.
  Python 2.7 always sets .reason, so it should be safe to use
  directly.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5715

AFFECTED FILES
  mercurial/statichttprepo.py

CHANGE DETAILS

diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -59,7 +59,7 @@
             num = inst.code == 404 and errno.ENOENT or None
             raise IOError(num, inst)
         except urlerr.urlerror as inst:
-            raise IOError(None, inst.reason[1])
+            raise IOError(None, inst.reason)
 
         if code == 200:
             # HTTPRangeHandler does nothing if remote does not support



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list