changeset 41441:b5169e79c31c

dispatch: add inline comment about possible IOError subtypes It's hard to tell which "if" would handle which exception.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 26 Jan 2019 17:44:07 +0900
parents 26761665bdfe
children b6673e9bdcf6
files mercurial/scmutil.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Sat Jan 26 16:53:17 2019 -0800
+++ b/mercurial/scmutil.py	Sat Jan 26 17:44:07 2019 +0900
@@ -232,9 +232,9 @@
         elif m in "zlib".split():
             ui.error(_("(is your Python install correct?)\n"))
     except IOError as inst:
-        if util.safehasattr(inst, "code"):
+        if util.safehasattr(inst, "code"): # HTTPError
             ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst))
-        elif util.safehasattr(inst, "reason"):
+        elif util.safehasattr(inst, "reason"): # URLError or SSLError
             try: # usually it is in the form (errno, strerror)
                 reason = inst.reason.args[1]
             except (AttributeError, IndexError):
@@ -247,14 +247,14 @@
         elif (util.safehasattr(inst, "args")
               and inst.args and inst.args[0] == errno.EPIPE):
             pass
-        elif getattr(inst, "strerror", None):
+        elif getattr(inst, "strerror", None): # common IOError
             if getattr(inst, "filename", None):
                 ui.error(_("abort: %s: %s\n") % (
                     encoding.strtolocal(inst.strerror),
                     stringutil.forcebytestr(inst.filename)))
             else:
                 ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
-        else:
+        else: # suspicious IOError
             raise
     except OSError as inst:
         if getattr(inst, "filename", None) is not None: