Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../lib2to3/fixes
File: fix_exec.py
# Copyright 2006 Google, Inc. All Rights Reserved.
[0] Fix | Delete
# Licensed to PSF under a Contributor Agreement.
[1] Fix | Delete
[2] Fix | Delete
"""Fixer for exec.
[3] Fix | Delete
[4] Fix | Delete
This converts usages of the exec statement into calls to a built-in
[5] Fix | Delete
exec() function.
[6] Fix | Delete
[7] Fix | Delete
exec code in ns1, ns2 -> exec(code, ns1, ns2)
[8] Fix | Delete
"""
[9] Fix | Delete
[10] Fix | Delete
# Local imports
[11] Fix | Delete
from .. import fixer_base
[12] Fix | Delete
from ..fixer_util import Comma, Name, Call
[13] Fix | Delete
[14] Fix | Delete
[15] Fix | Delete
class FixExec(fixer_base.BaseFix):
[16] Fix | Delete
BM_compatible = True
[17] Fix | Delete
[18] Fix | Delete
PATTERN = """
[19] Fix | Delete
exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >
[20] Fix | Delete
|
[21] Fix | Delete
exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
[22] Fix | Delete
"""
[23] Fix | Delete
[24] Fix | Delete
def transform(self, node, results):
[25] Fix | Delete
assert results
[26] Fix | Delete
syms = self.syms
[27] Fix | Delete
a = results["a"]
[28] Fix | Delete
b = results.get("b")
[29] Fix | Delete
c = results.get("c")
[30] Fix | Delete
args = [a.clone()]
[31] Fix | Delete
args[0].prefix = ""
[32] Fix | Delete
if b is not None:
[33] Fix | Delete
args.extend([Comma(), b.clone()])
[34] Fix | Delete
if c is not None:
[35] Fix | Delete
args.extend([Comma(), c.clone()])
[36] Fix | Delete
[37] Fix | Delete
return Call(Name("exec"), args, prefix=node.prefix)
[38] Fix | Delete
[39] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function