+++ /dev/null
-# Copyright 2006 Google, Inc. All Rights Reserved.\r
-# Licensed to PSF under a Contributor Agreement.\r
-\r
-"""Fixer for exec.\r
-\r
-This converts usages of the exec statement into calls to a built-in\r
-exec() function.\r
-\r
-exec code in ns1, ns2 -> exec(code, ns1, ns2)\r
-"""\r
-\r
-# Local imports\r
-from .. import pytree\r
-from .. import fixer_base\r
-from ..fixer_util import Comma, Name, Call\r
-\r
-\r
-class FixExec(fixer_base.BaseFix):\r
- BM_compatible = True\r
-\r
- PATTERN = """\r
- exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >\r
- |\r
- exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >\r
- """\r
-\r
- def transform(self, node, results):\r
- assert results\r
- syms = self.syms\r
- a = results["a"]\r
- b = results.get("b")\r
- c = results.get("c")\r
- args = [a.clone()]\r
- args[0].prefix = ""\r
- if b is not None:\r
- args.extend([Comma(), b.clone()])\r
- if c is not None:\r
- args.extend([Comma(), c.clone()])\r
-\r
- return Call(Name(u"exec"), args, prefix=node.prefix)\r