source: python/trunk/Lib/lib2to3/fixes/fix_input.py

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 709 bytes
Line 
1"""Fixer that changes input(...) into eval(input(...))."""
2# Author: Andre Roberge
3
4# Local imports
5from .. import fixer_base
6from ..fixer_util import Call, Name
7from .. import patcomp
8
9
10context = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >")
11
12
13class FixInput(fixer_base.BaseFix):
14 BM_compatible = True
15 PATTERN = """
16 power< 'input' args=trailer< '(' [any] ')' > >
17 """
18
19 def transform(self, node, results):
20 # If we're already wrapped in a eval() call, we're done.
21 if context.match(node.parent.parent):
22 return
23
24 new = node.clone()
25 new.prefix = u""
26 return Call(Name(u"eval"), [new], prefix=node.prefix)
Note: See TracBrowser for help on using the repository browser.