[PATCH 1 of 4] py3: work around the scope of exception variable in dispatch.run()

Yuya Nishihara yuya at tcha.org
Wed Oct 4 14:53:54 UTC 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1506923530 -3600
#      Mon Oct 02 06:52:10 2017 +0100
# Node ID bc4545271d0456e83e49667e1613057918f38093
# Parent  c67db5dc131d0facdfdadc8c3344a8f3e689867d
py3: work around the scope of exception variable in dispatch.run()

https://stackoverflow.com/questions/29268892/

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -79,12 +79,14 @@ def run():
     err = None
     try:
         status = (dispatch(req) or 0) & 255
-    except error.StdioError as err:
+    except error.StdioError as e:
+        err = e
         status = -1
     if util.safehasattr(req.ui, 'fout'):
         try:
             req.ui.fout.flush()
-        except IOError as err:
+        except IOError as e:
+            err = e
             status = -1
     if util.safehasattr(req.ui, 'ferr'):
         if err is not None and err.errno != errno.EPIPE:


More information about the Mercurial-devel mailing list