ยปCore Development>Code coverage>Lib/lib2to3/fixes/fix_input.py

Python code coverage for Lib/lib2to3/fixes/fix_input.py

#countcontent
1n/a"""Fixer that changes input(...) into eval(input(...))."""
2n/a# Author: Andre Roberge
3n/a
4n/a# Local imports
5n/afrom .. import fixer_base
6n/afrom ..fixer_util import Call, Name
7n/afrom .. import patcomp
8n/a
9n/a
10n/acontext = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >")
11n/a
12n/a
13n/aclass FixInput(fixer_base.BaseFix):
14n/a BM_compatible = True
15n/a PATTERN = """
16n/a power< 'input' args=trailer< '(' [any] ')' > >
17n/a """
18n/a
19n/a def transform(self, node, results):
20n/a # If we're already wrapped in an eval() call, we're done.
21n/a if context.match(node.parent.parent):
22n/a return
23n/a
24n/a new = node.clone()
25n/a new.prefix = ""
26n/a return Call(Name("eval"), [new], prefix=node.prefix)