[New-bugs-announce] [issue27757] eval() does not allow import statements to run.

Decorater report at bugs.python.org
Sat Aug 13 19:23:40 EDT 2016


New submission from Decorater:

runnign exec on import lines are fine however if I run the following code in a exec:

>>>import py2pycx;py2pycx.api.compress_script(sys.path[0] + '\resources\Dependencies', 'six.py')
Traceback (most recent call last):
  File ".\resources\Dependencies\DecoraterBotCore\BotCommands.py", line 261, in debug_code
    debugcode = eval(debugcode)
  File "<string>", line 1
    import py2pycx;py2pycx.api.compress_script(sys.path[0] + '\resources\Dependencies\', 'six.py')
         ^
SyntaxError: invalid syntax

It says it is a SyntaxError. It would be nice if eval could support import statements as well so I do not have to import the module in the file/package to be able to use eval with the functions it has.

----------
messages: 272621
nosy: Decorater
priority: normal
severity: normal
status: open
title: eval() does not allow import statements to run.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27757>
_______________________________________


More information about the New-bugs-announce mailing list