Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better fixer for unicode invokes that disables accidental attribute r…

…ewrites. This fixes #1
  • Loading branch information...
commit 7b7ef0304a40ecfe21cd70feaa971210f560ad17 1 parent c1ff4ca
Armin Ronacher authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 libmodernize/fixes/fix_unicode.py
15 libmodernize/fixes/fix_unicode.py
View
@@ -8,14 +8,19 @@
class FixUnicode(fixer_base.BaseFix):
BM_compatible = True
- PATTERN = "STRING | 'unicode'"
+ PATTERN = """
+ STRING |
+ power< name='unicode'
+ trailer< '(' [any] ')' >
+ any *
+ >
+ """
def transform(self, node, results):
- if node.type == token.NAME:
+ if 'name' in results:
touch_import(None, u'six', node)
- new = node.clone()
- new.value = u'six.text_type'
- return new
+ name = results['name']
+ name.replace(Name(u'six.text_type', prefix=name.prefix))
elif node.type == token.STRING and _literal_re.match(node.value):
touch_import(None, u'six', node)
new = node.clone()
Please sign in to comment.
Something went wrong with that request. Please try again.