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

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 4, 2017, 2:53 p.m.
Message ID <bc4545271d0456e83e49.1507128834@mimosa>
Download mbox | patch
Permalink /patch/24491/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 4, 2017, 2:53 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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/

Patch

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: