compat: don't reference an exception var inside a lambda
authorAlejandro Santos <alejolp@alejolp.com>
Sun, 05 Jul 2009 11:05:31 +0200
changeset 9035 8e34f363dd77
parent 9034 8429062de8d3
child 9036 32e678f9045f
compat: don't reference an exception var inside a lambda
mercurial/commands.py
--- a/mercurial/commands.py	Sun Jul 05 11:04:55 2009 +0200
+++ b/mercurial/commands.py	Sun Jul 05 11:05:31 2009 +0200
@@ -1457,7 +1457,10 @@
         try:
             aliases, i = cmdutil.findcmd(name, table, False)
         except error.AmbiguousCommand, inst:
-            select = lambda c: c.lstrip('^').startswith(inst.args[0])
+            # py3k fix: except vars can't be used outside the scope of the
+            # except block, nor can be used inside a lambda. python issue4617
+            prefix = inst.args[0]
+            select = lambda c: c.lstrip('^').startswith(prefix)
             helplist(_('list of commands:\n\n'), select)
             return