grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Allow code that uses `exec` to fail on run time instead of compile time #122

Closed alanjds closed 6 years ago

alanjds commented 6 years ago

On the same spirit of #118, simple having a code that have exec on it does not mean that it will be called. Should compile and maybe raise a NotImplementedError on runtime, if called.

try:
    from math import sum
except ImportError:
    exec '2+2'

and:

$ grumpy -c 'exec "2+2"'
Traceback (most recent call last):
  File "/Users/alanjds/src/git/grumpy/grumpy-tools-src/__main__.py", line 1, in <module>
NotImplementedError: exec is not available on Grumpy. Maybe never be.