Repository: serge-sans-paille/gast

Issue:
Python 3.6 f-strings are not supported by gast
What happens with `gast`:
```sh
$ python3.6 -c "import gast; print(gast.dump(gast.parse('f\'{x}\'')))"
Module(body=[Expr(value=None)])
```

What happens with standard `ast`:
```sh
$ python3.6 -c "import ast; print(ast.dump(ast.parse('f\'{x}\'')))"
Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=-1, format_spec=None)]))])
```



Discussion:

Patch:
diff --git a/README.rst b/README.rst
index 1a82f5c..1fea29c 100644
--- a/README.rst
+++ b/README.rst
@@ -151,6 +151,11 @@ ASDL
               | Import(alias* names)
               | ImportFrom(identifier? module, alias* names, int? level)
 
+              -- Doesn't capture requirement that locals must be
+              -- defined if globals is
+              -- still supports use as a function!
+              | Exec(expr body, expr? globals, expr? locals)
+
               | Global(identifier* names)
               | Nonlocal(identifier* names)
               | Expr(expr value)
@@ -180,8 +185,11 @@ ASDL
              -- x < 4 < 3 and (x < 4) < 3
              | Compare(expr left, cmpop* ops, expr* comparators)
              | Call(expr func, expr* args, keyword* keywords)
+             | Repr(expr value)
              | Num(object n) -- a number as a PyObject.
              | Str(string s) -- need to specify raw, unicode, etc?
+             | FormattedValue(expr value, int? conversion, expr? format_spec)
+             | JoinedStr(expr* values)
              | Bytes(bytes s)
              | NameConstant(singleton value)
              | Ellipsis
diff --git a/gast/gast.py b/gast/gast.py
index f1bf062..fcbd656 100644
--- a/gast/gast.py
+++ b/gast/gast.py
@@ -132,6 +132,9 @@ _nodes = {
             (expr,)),
     'Str': (('s',), ('lineno', 'col_offset',),
             (expr,)),
+    'FormattedValue': (('value', 'conversion', 'format_spec',),
+                       ('lineno', 'col_offset',), (expr,)),
+    'JoinedStr': (('values',), ('lineno', 'col_offset',), (expr,)),
     'Bytes': (('s',), ('lineno', 'col_offset',),
               (expr,)),
     'NameConstant': (('value',), ('lineno', 'col_offset',),
diff --git a/tox.ini b/tox.ini
index 7f0c4e1..4a2a146 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py27,py30,py31,py32,py33,py34,py35
+envlist = py27,py30,py31,py32,py33,py34,py35,py36
 [testenv]
 deps =
     astunparse


Test patch:
diff --git a/tests/test_compat.py b/tests/test_compat.py
index 9faed17..fdf0b0d 100644
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -62,6 +62,18 @@ class CompatTestCase(unittest.TestCase):
             tree = gast.parse(code)
             compile(gast.gast_to_ast(tree), '<test>', 'exec')
 
+        if sys.version_info.minor >= 6:
+
+            def test_FormattedValue(self):
+                code = 'e = 1; f"{e}"'
+                tree = gast.parse(code)
+                compile(gast.gast_to_ast(tree), '<test>', 'exec')
+
+            def test_JoinedStr(self):
+                code = 'e = 1; f"e = {e}"'
+                tree = gast.parse(code)
+                compile(gast.gast_to_ast(tree), '<test>', 'exec')
+
 
 if __name__ == '__main__':
     unittest.main()