Patchwork [3,of,3] dispatch: unify handler of IOError and OSError

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 26, 2019, 9:24 a.m.
Message ID <76f6d37dfe338f6887de.1548494671@mimosa>
Download mbox | patch
Permalink /patch/38084/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 26, 2019, 9:24 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1548492783 -32400
#      Sat Jan 26 17:53:03 2019 +0900
# Node ID 76f6d37dfe338f6887de6cfca483f2baef39724d
# Parent  83cd7b49057adc113d349eba2af6d3da38d3a5af
dispatch: unify handler of IOError and OSError

These exceptions were merged in Python 3.
via Mercurial-devel - Jan. 28, 2019, 5:47 a.m.
On Sat, Jan 26, 2019 at 1:29 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1548492783 -32400
> #      Sat Jan 26 17:53:03 2019 +0900
> # Node ID 76f6d37dfe338f6887de6cfca483f2baef39724d
> # Parent  83cd7b49057adc113d349eba2af6d3da38d3a5af
> dispatch: unify handler of IOError and OSError
>

Queued, thanks.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -231,7 +231,7 @@  def callcatch(ui, func):
             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 @@  def callcatch(ui, func):
         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 @@  def callcatch(ui, func):
                 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: