# HG changeset patch # User Yuya Nishihara # Date 1548492247 -32400 # Node ID b5169e79c31c1bb2891f4e9bc8c09f95dddc48b1 # Parent 26761665bdfe8948089cbecb9adae693f0cf617c dispatch: add inline comment about possible IOError subtypes It's hard to tell which "if" would handle which exception. diff -r 26761665bdfe -r b5169e79c31c mercurial/scmutil.py --- 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: