diff options
Diffstat (limited to 'Lib/lib2to3/fixer_base.py')
-rw-r--r-- | Lib/lib2to3/fixer_base.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/lib2to3/fixer_base.py b/Lib/lib2to3/fixer_base.py index df581a4..2f50ad3 100644 --- a/Lib/lib2to3/fixer_base.py +++ b/Lib/lib2to3/fixer_base.py @@ -26,6 +26,7 @@ class BaseFix(object): pattern_tree = None # Tree representation of the pattern options = None # Options object passed to initializer filename = None # The filename (set by set_filename) + logger = None # A logger (set by set_filename) numbers = itertools.count(1) # For new_name() used_names = set() # A set of all used NAMEs order = "post" # Does the fixer prefer pre- or post-order traversal @@ -68,7 +69,7 @@ class BaseFix(object): with_tree=True) def set_filename(self, filename): - """Set the filename. + """Set the filename, and a logger derived from it. The main refactoring tool should call this. """ @@ -102,14 +103,14 @@ class BaseFix(object): """ raise NotImplementedError() - def new_name(self, template="xxx_todo_changeme"): + def new_name(self, template=u"xxx_todo_changeme"): """Return a string suitable for use as an identifier The new name is guaranteed not to conflict with other identifiers. """ name = template while name in self.used_names: - name = template + str(next(self.numbers)) + name = template + unicode(self.numbers.next()) self.used_names.add(name) return name @@ -128,7 +129,7 @@ class BaseFix(object): """ lineno = node.get_lineno() for_output = node.clone() - for_output.prefix = "" + for_output.prefix = u"" msg = "Line %d: could not convert: %s" self.log_message(msg % (lineno, for_output)) if reason: |