dispatch: unify handler of IOError and OSError
authorYuya Nishihara <yuya@tcha.org>
Sat, 26 Jan 2019 17:53:03 +0900
changeset 41421 f83b230b7fb3
parent 41420 b6673e9bdcf6
child 41422 d3a7c743ae3b
dispatch: unify handler of IOError and OSError These exceptions were merged in Python 3.
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Sat Jan 26 17:51:55 2019 +0900
+++ b/mercurial/scmutil.py	Sat Jan 26 17:53:03 2019 +0900
@@ -231,7 +231,7 @@
             ui.error(_("(did you forget to compile extensions?)\n"))
         elif m in "zlib".split():
             ui.error(_("(is your Python install correct?)\n"))
-    except IOError as inst:
+    except (IOError, OSError) as inst:
         if util.safehasattr(inst, "code"): # HTTPError
             ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst))
         elif util.safehasattr(inst, "reason"): # URLError or SSLError
@@ -247,7 +247,7 @@
         elif (util.safehasattr(inst, "args")
               and inst.args and inst.args[0] == errno.EPIPE):
             pass
-        elif getattr(inst, "strerror", None): # common IOError
+        elif getattr(inst, "strerror", None): # common IOError or OSError
             if getattr(inst, "filename", None) is not None:
                 ui.error(_("abort: %s: '%s'\n") % (
                     encoding.strtolocal(inst.strerror),
@@ -256,13 +256,6 @@
                 ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
         else: # suspicious IOError
             raise
-    except OSError as inst:
-        if getattr(inst, "filename", None) is not 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))
     except MemoryError:
         ui.error(_("abort: out of memory\n"))
     except SystemExit as inst: