]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35224: Add support for NamedExpr to unparse.py (GH-11670)
authorVictor Stinner <vstinner@redhat.com>
Fri, 25 Jan 2019 00:49:53 +0000 (01:49 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Jan 2019 00:49:53 +0000 (01:49 +0100)
Tools/parser/unparse.py

index 82c3c776807283abfb7f1fd4bce790ba6bdb5f16..70b47a17405312f281c3e421718b363c9426c551 100644 (file)
@@ -79,6 +79,13 @@ class Unparser:
         self.fill()
         self.dispatch(tree.value)
 
+    def _NamedExpr(self, tree):
+        self.write("(")
+        self.dispatch(tree.target)
+        self.write(" := ")
+        self.dispatch(tree.value)
+        self.write(")")
+
     def _Import(self, t):
         self.fill("import ")
         interleave(lambda: self.write(", "), self.dispatch, t.names)