summaryrefslogtreecommitdiff
path: root/Lib/lib2to3/refactor.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/lib2to3/refactor.py')
-rw-r--r--Lib/lib2to3/refactor.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index 55fd60fa27..3a5aafffc6 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -155,6 +155,7 @@ class FixerError(Exception):
class RefactoringTool(object):
_default_options = {"print_function" : False,
+ "exec_function": False,
"write_unchanged_files" : False}
CLASS_PREFIX = "Fix" # The prefix for fixer classes
@@ -173,10 +174,13 @@ class RefactoringTool(object):
self.options = self._default_options.copy()
if options is not None:
self.options.update(options)
- if self.options["print_function"]:
- self.grammar = pygram.python_grammar_no_print_statement
- else:
- self.grammar = pygram.python_grammar
+ self.grammar = pygram.python_grammar.copy()
+
+ if self.options['print_function']:
+ del self.grammar.keywords["print"]
+ elif self.options['exec_function']:
+ del self.grammar.keywords["exec"]
+
# When this is True, the refactor*() methods will call write_file() for
# files processed even if they were not changed during refactoring. If
# and only if the refactor method's write parameter was True.