caterinaurban / Typpete

34 stars 6 forks source link

SyntaxError when running Typpete with Python 3.7 #51

Closed FChris closed 5 years ago

FChris commented 6 years ago

When running Typpete with Python 3.7 and the following example file I get an SyntaxError: invalid syntax

Example file:

from abc import ABCMeta, abstractmethod

class Item (metaclass=ABCMeta):
    @abstractmethod
    def compete(self, item):
        pass

    def evalEven(self, item):
        return "WIN"

    def evalOdd(self, item):
        return "LOSE"

class Even(Item):
    def compete(self, item):
        return item.evalEven(self)

class Odd(Item):
    def compete(self, item):
        return item.evalOdd(self)

def match(item1, item2):
    return item1.compete(item2)
Traceback (most recent call last):
  File "venv/bin/typpete", line 7, in <module>
    from typpete.inference_runner import run_inference
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/inference_runner.py", line 1, in <module>
    from typpete.src.stmt_inferrer import *
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/src/stmt_inferrer.py", line 24, in <module>
    import typpete.src.expr_inferrer as expr
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/src/expr_inferrer.py", line 35, in <module>
    import typpete.src.z3_axioms as axioms
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/src/z3_axioms.py", line 2, in <module>
    from typpete.src.z3_types import And, Or, Implies, Not
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/src/z3_types.py", line 13, in <module>
    from typpete.src.pre_analysis import PreAnalyzer
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/src/pre_analysis.py", line 6, in <module>
    from typpete.src.import_handler import ImportHandler
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/typpete/src/import_handler.py", line 2, in <module>
    import astunparse
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/astunparse/__init__.py", line 4, in <module>
    from .unparser import Unparser
  File "~/tmp/Typpete/venv/lib/python3.7/site-packages/astunparse/unparser.py", line 331
    def _generic_FunctionDef(self, t, async=False):
                                          ^
SyntaxError: invalid syntax
ethanhs commented 6 years ago

It looks like astunparse doesn't work with async being a keyword. The solution is probably to install it from git. (see https://github.com/simonpercivall/astunparse/issues/26)

FChris commented 6 years ago

Thank you. This solved the issue. However I still get a

[1]    31581 segmentation fault (core dumped)  venv/bin/typpete example.py

I doubt, however, that this is related to Python 3.7 Not sure how to track this error down though.

Edit: The other error seems to have been a problem with the z3 installation on my system. I am closing this issue as it is not a typpete problem. Thanks :-)