fijal / jitpy

Library to embed PyPy into CPython
MIT License
242 stars 17 forks source link

invalid syntax: exec source.compile() in namespace #8

Closed NeighborhoodCoding closed 4 years ago

NeighborhoodCoding commented 4 years ago

I'm win10 64bit user and i run your code as below

from jitpy.wrapper import jittify @jittify([int, float], float) def func(count, no): s = 0 for i in range(count): s += no return s func(1000, 1.2)

but it has an error as follows. why is that? cuz am i using 64bit windows?

Traceback (most recent call last): File "c:\users\owner\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in from jitpy.wrapper import jittify

File "c:\users\owner\appdata\local\programs\python\python36\lib\site-packages\jitpy\wrapper.py", line 68 exec source.compile() in namespace ^ SyntaxError: invalid syntax

mattip commented 4 years ago

The code supports python2 semantics. This should become exec(source.compile, namespace)

mattip commented 4 years ago

Sorry, the code already has exec(source.compile, namespace). What version of PyPy are you using?

arigo commented 4 years ago

@mattip You're confused, there are two levels of exec in this traceback. The one in File c:\users\owner\appdata\local\programs\python\python36\lib\site-packages\jitpy\wrapper.py is using Python 2 syntax (and I doubt it would just work on Python 3.x out of the box once this line is fixed, but it's probably not a lot of work overall).

arigo commented 4 years ago

Sorry, I closed this issue thinking there is no plan to officially upgrade this old stuff. Please reopen if I'm wrong.