diff options
Diffstat (limited to 'Lib/lib2to3/fixes/fix_except.py')
-rw-r--r-- | Lib/lib2to3/fixes/fix_except.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/lib2to3/fixes/fix_except.py b/Lib/lib2to3/fixes/fix_except.py index 49bd3d5..e324718 100644 --- a/Lib/lib2to3/fixes/fix_except.py +++ b/Lib/lib2to3/fixes/fix_except.py @@ -30,7 +30,7 @@ from ..fixer_util import Assign, Attr, Name, is_tuple, is_list, syms def find_excepts(nodes): for i, n in enumerate(nodes): if n.type == syms.except_clause: - if n.children[0].value == 'except': + if n.children[0].value == u'except': yield (n, nodes[i+2]) class FixExcept(fixer_base.BaseFix): @@ -53,13 +53,13 @@ class FixExcept(fixer_base.BaseFix): for except_clause, e_suite in find_excepts(try_cleanup): if len(except_clause.children) == 4: (E, comma, N) = except_clause.children[1:4] - comma.replace(Name("as", prefix=" ")) + comma.replace(Name(u"as", prefix=u" ")) if N.type != token.NAME: # Generate a new N for the except clause - new_N = Name(self.new_name(), prefix=" ") + new_N = Name(self.new_name(), prefix=u" ") target = N.clone() - target.prefix = "" + target.prefix = u"" N.replace(new_N) new_N = new_N.clone() @@ -75,7 +75,7 @@ class FixExcept(fixer_base.BaseFix): # The assignment is different if old_N is a tuple or list # In that case, the assignment is old_N = new_N.args if is_tuple(N) or is_list(N): - assign = Assign(target, Attr(new_N, Name('args'))) + assign = Assign(target, Attr(new_N, Name(u'args'))) else: assign = Assign(target, new_N) @@ -83,10 +83,10 @@ class FixExcept(fixer_base.BaseFix): for child in reversed(suite_stmts[:i]): e_suite.insert_child(0, child) e_suite.insert_child(i, assign) - elif N.prefix == "": + elif N.prefix == u"": # No space after a comma is legal; no space after "as", # not so much. - N.prefix = " " + N.prefix = u" " #TODO(cwinter) fix this when children becomes a smart list children = [c.clone() for c in node.children[:3]] + try_cleanup + tail |