Kaydet (Commit) ea0dec38 authored tarafından Kodi Arfer's avatar Kodi Arfer Kaydeden (comit) Berker Peksag

Add Python 3.8 support (#133)

* Fix code generation with attributes of integer literals
* Handle Constant.kind since it was only added in Python 3
* Remove allow_failures for Python 3.8 from .travis.yml
üst 33e005b8
......@@ -17,8 +17,6 @@ matrix:
- python: 3.8-dev
sudo: required
dist: xenial
allow_failures:
- python: 3.8-dev
cache: pip
install:
- pip install tox-travis
......
......@@ -534,8 +534,9 @@ class SourceGenerator(ExplicitNodeVisitor):
def visit_Constant(self, node):
value = node.value
if isinstance(value, (float, complex)):
self._handle_numeric_constant(value)
if isinstance(value, (int, float, complex)):
with self.delimit(node):
self._handle_numeric_constant(value)
elif isinstance(value, str):
self._handle_string_constant(node, node.value)
elif value is Ellipsis:
......@@ -614,6 +615,9 @@ class SourceGenerator(ExplicitNodeVisitor):
if is_joined:
mystr = 'f' + mystr
elif getattr(node, 'kind', False):
# Constant.kind is a Python 3.8 addition.
mystr = node.kind + mystr
self.write(mystr)
......
......@@ -78,6 +78,7 @@ op_data = """
Pow ** 1
Await 1
Num 1
Constant 1
"""
op_data = [x.split() for x in op_data.splitlines()]
......
......@@ -29,6 +29,12 @@ Bug fixes
.. _`Issue 124`: https://github.com/berkerpeksag/astor/issues/124
.. _`PR 125`: https://github.com/berkerpeksag/astor/pull/125
* Fixed code generation with attributes of integer literals, and
with ``u``-prefixed string literals.
(Fixed by Kodi Arfer in `PR 133`_.)
.. _`PR 133`: https://github.com/berkerpeksag/astor/pull/133
0.7.1 - 2018-07-06
------------------
......
......@@ -19,11 +19,11 @@ classifiers =
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: Implementation
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
......
......@@ -181,6 +181,10 @@ class CodegenTestCase(unittest.TestCase, Comparisons):
# Probably also works on < 3.4, but doesn't work on 2.7...
self.assertSrcRoundtripsGtVer(source, (3, 4), (2, 7))
def test_attribute(self):
self.assertSrcRoundtrips("x.foo")
self.assertSrcRoundtrips("(5).foo")
def test_matrix_multiplication(self):
for source in ("(a @ b)", "a @= b"):
self.assertAstRoundtripsGtVer(source, (3, 5))
......
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