Unverified Kaydet (Commit) fe1ef7f9 authored tarafından Berker Peksag's avatar Berker Peksag Kaydeden (comit) GitHub

Don't use 'async' as a keyword argument (#94)

Fixes #86
üst 7b0fa748
......@@ -9,9 +9,11 @@ python:
- 3.6
- pypy
- pypy3.3-5.2-alpha1
- 3.7-dev
matrix:
allow_failures:
- python: 2.6
- python: 3.7-dev
cache: pip
install:
- pip install tox-travis
......
......@@ -308,8 +308,8 @@ class SourceGenerator(ExplicitNodeVisitor):
self.statement(node)
self.generic_visit(node)
def visit_FunctionDef(self, node, async=False):
prefix = 'async ' if async else ''
def visit_FunctionDef(self, node, is_async=False):
prefix = 'async ' if is_async else ''
self.decorators(node, 1 if self.indentation else 2)
self.statement(node, '%sdef %s' % (prefix, node.name), '(')
self.visit_arguments(node.args)
......@@ -322,7 +322,7 @@ class SourceGenerator(ExplicitNodeVisitor):
# introduced in Python 3.5
def visit_AsyncFunctionDef(self, node):
self.visit_FunctionDef(node, async=True)
self.visit_FunctionDef(node, is_async=True)
def visit_ClassDef(self, node):
have_args = []
......@@ -364,24 +364,24 @@ class SourceGenerator(ExplicitNodeVisitor):
self.else_body(else_)
break
def visit_For(self, node, async=False):
def visit_For(self, node, is_async=False):
set_precedence(node, node.target)
prefix = 'async ' if async else ''
prefix = 'async ' if is_async else ''
self.statement(node, '%sfor ' % prefix,
node.target, ' in ', node.iter, ':')
self.body_or_else(node)
# introduced in Python 3.5
def visit_AsyncFor(self, node):
self.visit_For(node, async=True)
self.visit_For(node, is_async=True)
def visit_While(self, node):
set_precedence(node, node.test)
self.statement(node, 'while ', node.test, ':')
self.body_or_else(node)
def visit_With(self, node, async=False):
prefix = 'async ' if async else ''
def visit_With(self, node, is_async=False):
prefix = 'async ' if is_async else ''
self.statement(node, '%swith ' % prefix)
if hasattr(node, "context_expr"): # Python < 3.3
self.visit_withitem(node)
......@@ -392,7 +392,7 @@ class SourceGenerator(ExplicitNodeVisitor):
# new for Python 3.5
def visit_AsyncWith(self, node):
self.visit_With(node, async=True)
self.visit_With(node, is_async=True)
# new for Python 3.3
def visit_withitem(self, node):
......
......@@ -2,6 +2,27 @@
Release Notes
=============
0.7.0 - 2018-03-24
------------------
New features
~~~~~~~~~~~~
* Added initial support for Python 3.7.0.
Note that if you have a subclass of ``astor.code_gen.SourceGenerator``, you
may need to rename the keyword argument ``async`` of the following methods
to ``is_async``:
- ``visit_FunctionDef(..., is_async=False)``
- ``visit_For(..., is_async=False)``
- ``visit_With(..., is_async=False)``
(Reported and fixed by Berker Peksag in `Issue 86`_.)
.. _`Issue 86`: https://github.com/berkerpeksag/astor/issues/86
0.6.2 - 2017-11-11
------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment