google / tangent

Source-to-Source Debuggable Derivatives in Pure Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python 3.8 compatibility (gast >= 0.3.0 has breaking changes to API)

singularperturbation opened this issue · comments

As referenced in the 3.8 documentation, the ast.Num, ast.Str, etc. classes are deprecated and being removed in future versions.

To support this (?), the gast library has changed to replace these with gast.Constant instead. (I.e., a gast.Num would be gast.Constant(value=1, kind=None) instead of gast.Num(n=1)).

Unfortunately, this breaks tangent:

>>> import tangent
Traceback (most recent call last):                                                                                        
  File "<stdin>", line 1, in <module>
  File "/home/ssimmons/tangent/tangent/__init__.py", line 20, in <module>
    from tangent import annotate 
  File "/home/ssimmons/tangent/tangent/annotate.py", line 27, in <module>
    from tangent import cfg
  File "/home/ssimmons/tangent/tangent/cfg.py", line 29, in <module>
    from tangent import grammar
  File "/home/ssimmons/tangent/tangent/grammar.py", line 18, in <module>
    LITERALS = (gast.Num, gast.Str, gast.Bytes, gast.Ellipsis, gast.NameConstant)
AttributeError: module 'gast' has no attribute 'Num'

So I think that we need to restrict to the old API (and use Python <3.8) or adapt to the new API.