summaryrefslogtreecommitdiff
path: root/dev-python/astunparse
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/astunparse')
-rw-r--r--dev-python/astunparse/Manifest4
-rw-r--r--dev-python/astunparse/astunparse-1.6.2.ebuild12
-rw-r--r--dev-python/astunparse/files/astunparse-1.6.2-py38.patch259
-rw-r--r--dev-python/astunparse/files/astunparse-1.6.2-tests.patch23
4 files changed, 295 insertions, 3 deletions
diff --git a/dev-python/astunparse/Manifest b/dev-python/astunparse/Manifest
index 7585dcea2a2e..63fc25a3704b 100644
--- a/dev-python/astunparse/Manifest
+++ b/dev-python/astunparse/Manifest
@@ -1,3 +1,5 @@
+AUX astunparse-1.6.2-py38.patch 8802 BLAKE2B e6e303142bd91147fa6c90193c15319b77cb9b34535bcfc0eeec19de4233a22e8f954ae8460bf624590227a3f92e68be3d17c35330862fe9e447e63873276bca SHA512 18cf287f965c6cc9de961854e1bb3b344eb46557149a25f6f28bb70c4361ae15431a5a4579bf5c38a14ddad29e85fd2c13da3fa810c2e7474c4c7f6a5f001049
+AUX astunparse-1.6.2-tests.patch 707 BLAKE2B 00d45b4b6bfdc70828d173985533345798a5982fa4f345e83c07e39c58dafffbf2a50ae1657df02769351a402e66faec443f7e63604ef457517e570803c50b3b SHA512 d1a86860548e0b904cc70017e0b5fa3a4e8da6bd1c03571e196e01a660d31a3ae03dec77c36945d7b5e53920b2531f0a7a0a5e3edc15b5a61c53ddafe83156d4
DIST astunparse-1.6.2.tar.gz 16339 BLAKE2B d35d63b8313718c1d873d55b7da824465be9b4bc9e486ff82dac7db2df5185f8a59bfb283844d7108927b04ee02879fe921c87f9da8bd87c157341e6022b40cc SHA512 1e344354481dab7345d8790791e15e2ce733b8985839972a1771b97adebbfc2b42c8fb258ea36f245baed553d3b8e5007872d6559ebcc5ef1eb6f6c6a5d66c81
-EBUILD astunparse-1.6.2.ebuild 528 BLAKE2B 6ced8b8c0cc1d5bff0e3a9ab8bdbd064eb667f287df9c49592f8186d7bfe2363e5996815b19736bd2c6dc0146334669de3250a806ded9aea9269993b6e955875 SHA512 56a3355afb74fb6f5601ff36bbd13d50d752a8df87012fb153fba7712317572672cd3cac28a3db20316137d0430fc1159cef1a41bab1aea6193aaabd5df952bf
+EBUILD astunparse-1.6.2.ebuild 758 BLAKE2B ed28575ac18b3737755b6a7b3b53d31949cabceea4a1c673f564563bb433fb8029918a2f3dfbbe28aa2f550dcf0e2f8c2234d812615ae5eec8b680cbea352cdc SHA512 d8681984f8ec4942a9011fae5cc9ad936d3f3ffd7f04e90f0d76a53eb7035869e18ed734529eceb93e05262e76e12c9d21dbadbedeaa95d1f25c60e684eaf108
MISC metadata.xml 248 BLAKE2B 5d9c3678c604aac0f24c5d5015e28f02b9ce83bb6a179755a44adeb3d69e4dd50be4acc30a6317649f5be23bcf13ac210bbe4712aa403e9c4cf2de351b39c941 SHA512 dc5b06a888be6367909895d5891a08189f4657bcee602e5ff0021be2ad3677e58ec7387ff244625be66a142138666e7eac790d2a7b1e298f0ad644725b5e57e0
diff --git a/dev-python/astunparse/astunparse-1.6.2.ebuild b/dev-python/astunparse/astunparse-1.6.2.ebuild
index 304fa3dd21c9..f57695d4f84c 100644
--- a/dev-python/astunparse/astunparse-1.6.2.ebuild
+++ b/dev-python/astunparse/astunparse-1.6.2.ebuild
@@ -3,7 +3,7 @@
EAPI=7
-PYTHON_COMPAT=( python3_6 python3_7 )
+PYTHON_COMPAT=( python3_{6,7,8} )
inherit distutils-r1
DESCRIPTION="Astun parser for python"
@@ -12,12 +12,20 @@ SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
-KEYWORDS="~amd64"
+KEYWORDS="~amd64 ~x86"
RDEPEND="
>=dev-python/six-1.6.1[${PYTHON_USEDEP}]
>=dev-python/wheel-0.23.0[${PYTHON_USEDEP}]
"
+PATCHES=(
+ "${FILESDIR}/astunparse-1.6.2-tests.patch"
+
+ # https://github.com/simonpercivall/astunparse/commit/2bd946919076f993cee1173611914372a0a25f00
+ "${FILESDIR}/astunparse-1.6.2-py38.patch"
+)
+
+distutils_enable_tests setup.py
python_install_all() {
distutils-r1_python_install_all
diff --git a/dev-python/astunparse/files/astunparse-1.6.2-py38.patch b/dev-python/astunparse/files/astunparse-1.6.2-py38.patch
new file mode 100644
index 000000000000..aa27112393c0
--- /dev/null
+++ b/dev-python/astunparse/files/astunparse-1.6.2-py38.patch
@@ -0,0 +1,259 @@
+diff --git a/lib/astunparse/unparser.py b/lib/astunparse/unparser.py
+index edf8c68..0ef6fd8 100644
+--- a/lib/astunparse/unparser.py
++++ b/lib/astunparse/unparser.py
+@@ -29,7 +29,7 @@ class Unparser:
+ output source code for the abstract syntax; original formatting
+ is disregarded. """
+
+- def __init__(self, tree, file=sys.stdout):
++ def __init__(self, tree, file = sys.stdout):
+ """Unparser(tree, file=sys.stdout) -> None.
+ Print the source for tree to file."""
+ self.f = file
+@@ -89,6 +89,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)
+@@ -120,11 +127,11 @@ class Unparser:
+
+ def _AnnAssign(self, t):
+ self.fill()
+- if not t.simple:
+- self.write("(")
++ if not t.simple and isinstance(t.target, ast.Name):
++ self.write('(')
+ self.dispatch(t.target)
+- if not t.simple:
+- self.write(")")
++ if not t.simple and isinstance(t.target, ast.Name):
++ self.write(')')
+ self.write(": ")
+ self.dispatch(t.annotation)
+ if t.value:
+@@ -189,6 +196,14 @@ class Unparser:
+ self.fill("nonlocal ")
+ interleave(lambda: self.write(", "), self.write, t.names)
+
++ def _Await(self, t):
++ self.write("(")
++ self.write("await")
++ if t.value:
++ self.write(" ")
++ self.dispatch(t.value)
++ self.write(")")
++
+ def _Yield(self, t):
+ self.write("(")
+ self.write("yield")
+@@ -328,12 +343,19 @@ class Unparser:
+ self.dispatch(t.body)
+ self.leave()
+
+- def _generic_FunctionDef(self, t, async_=False):
++ def _FunctionDef(self, t):
++ self.__FunctionDef_helper(t, "def")
++
++ def _AsyncFunctionDef(self, t):
++ self.__FunctionDef_helper(t, "async def")
++
++ def __FunctionDef_helper(self, t, fill_suffix):
+ self.write("\n")
+ for deco in t.decorator_list:
+ self.fill("@")
+ self.dispatch(deco)
+- self.fill(("async " if async_ else "") + "def " + t.name + "(")
++ def_str = fill_suffix+" "+t.name + "("
++ self.fill(def_str)
+ self.dispatch(t.args)
+ self.write(")")
+ if getattr(t, "returns", False):
+@@ -343,14 +365,14 @@ class Unparser:
+ self.dispatch(t.body)
+ self.leave()
+
+- def _FunctionDef(self, t):
+- self._generic_FunctionDef(t)
++ def _For(self, t):
++ self.__For_helper("for ", t)
+
+- def _AsyncFunctionDef(self, t):
+- self._generic_FunctionDef(t, async_=True)
++ def _AsyncFor(self, t):
++ self.__For_helper("async for ", t)
+
+- def _generic_For(self, t, async_=False):
+- self.fill("async for " if async_ else "for ")
++ def __For_helper(self, fill, t):
++ self.fill(fill)
+ self.dispatch(t.target)
+ self.write(" in ")
+ self.dispatch(t.iter)
+@@ -363,12 +385,6 @@ class Unparser:
+ self.dispatch(t.orelse)
+ self.leave()
+
+- def _For(self, t):
+- self._generic_For(t)
+-
+- def _AsyncFor(self, t):
+- self._generic_For(t, async_=True)
+-
+ def _If(self, t):
+ self.fill("if ")
+ self.dispatch(t.test)
+@@ -586,8 +604,9 @@ class Unparser:
+
+ def _comprehension(self, t):
+ if getattr(t, 'is_async', False):
+- self.write(" async")
+- self.write(" for ")
++ self.write(" async for ")
++ else:
++ self.write(" for ")
+ self.dispatch(t.target)
+ self.write(" in ")
+ self.dispatch(t.iter)
+@@ -612,26 +631,27 @@ class Unparser:
+
+ def _Dict(self, t):
+ self.write("{")
+- def write_pair(pair):
+- (k, v) = pair
++ def write_key_value_pair(k, v):
++ self.dispatch(k)
++ self.write(": ")
++ self.dispatch(v)
++
++ def write_item(item):
++ k, v = item
+ if k is None:
+- self.write('**')
++ # for dictionary unpacking operator in dicts {**{'y': 2}}
++ # see PEP 448 for details
++ self.write("**")
+ self.dispatch(v)
+ else:
+- self.dispatch(k)
+- self.write(": ")
+- self.dispatch(v)
+- self.write(",")
+- self._indent +=1
+- self.fill("")
+- interleave(lambda: self.fill(""), write_pair, zip(t.keys, t.values))
+- self._indent -=1
+- self.fill("}")
++ write_key_value_pair(k, v)
++ interleave(lambda: self.write(", "), write_item, zip(t.keys, t.values))
++ self.write("}")
+
+ def _Tuple(self, t):
+ self.write("(")
+ if len(t.elts) == 1:
+- (elt,) = t.elts
++ elt = t.elts[0]
+ self.dispatch(elt)
+ self.write(",")
+ else:
+@@ -656,10 +676,9 @@ class Unparser:
+ self.dispatch(t.operand)
+ self.write(")")
+
+- binop = { "Add":"+", "Sub":"-", "Mult":"*", "Div":"/", "Mod":"%",
++ binop = { "Add":"+", "Sub":"-", "Mult":"*", "MatMult":"@", "Div":"/", "Mod":"%",
+ "LShift":"<<", "RShift":">>", "BitOr":"|", "BitXor":"^", "BitAnd":"&",
+- "FloorDiv":"//", "Pow": "**",
+- "MatMult":"@"}
++ "FloorDiv":"//", "Pow": "**"}
+ def _BinOp(self, t):
+ self.write("(")
+ self.dispatch(t.left)
+@@ -689,7 +708,7 @@ class Unparser:
+ # Special case: 3.__abs__() is a syntax error, so if t.value
+ # is an integer literal then we need to either parenthesize
+ # it or add an extra space to get 3 .__abs__().
+- if isinstance(t.value, ast.Num) and isinstance(t.value.n, int):
++ if isinstance(t.value, getattr(ast, 'Constant', getattr(ast, 'Num', None))) and isinstance(t.value.n, int):
+ self.write(" ")
+ self.write(".")
+ self.write(t.attr)
+@@ -760,18 +779,22 @@ class Unparser:
+ def _arguments(self, t):
+ first = True
+ # normal arguments
+- defaults = [None] * (len(t.args) - len(t.defaults)) + t.defaults
+- for a,d in zip(t.args, defaults):
++ all_args = getattr(t, 'posonlyargs', []) + t.args
++ defaults = [None] * (len(all_args) - len(t.defaults)) + t.defaults
++ for index, elements in enumerate(zip(all_args, defaults), 1):
++ a, d = elements
+ if first:first = False
+ else: self.write(", ")
+ self.dispatch(a)
+ if d:
+ self.write("=")
+ self.dispatch(d)
++ if index == len(getattr(t, 'posonlyargs', ())):
++ self.write(", /")
+
+ # varargs, or bare '*' if no varargs but keyword-only arguments present
+ if t.vararg or getattr(t, "kwonlyargs", False):
+- if first: first = False
++ if first:first = False
+ else: self.write(", ")
+ self.write("*")
+ if t.vararg:
+@@ -839,14 +862,6 @@ class Unparser:
+ self.write(" as ")
+ self.dispatch(t.optional_vars)
+
+- def _Await(self, t):
+- self.write("(")
+- self.write("await")
+- if t.value:
+- self.write(" ")
+- self.dispatch(t.value)
+- self.write(")")
+-
+ def roundtrip(filename, output=sys.stdout):
+ if six.PY3:
+ with open(filename, "rb") as pyfile:
+diff --git a/setup.py b/setup.py
+index 6f62fd9..e5a277a 100755
+--- a/setup.py
++++ b/setup.py
+@@ -48,11 +48,10 @@ setup(
+ "Programming Language :: Python :: 2",
+ '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',
+ 'Topic :: Software Development :: Code Generators',
+ ],
+ test_suite='tests',
+diff --git a/tests/common.py b/tests/common.py
+index c8db903..95b9755 100644
+--- a/tests/common.py
++++ b/tests/common.py
+@@ -215,6 +215,7 @@ class AstunparseCommonTestCase:
+ self.check_roundtrip("not True or False")
+ self.check_roundtrip("True or not False")
+
++ @unittest.skipUnless(sys.version_info < (3, 6), "Only works for Python < 3.6")
+ def test_integer_parens(self):
+ self.check_roundtrip("3 .__abs__()")
+
diff --git a/dev-python/astunparse/files/astunparse-1.6.2-tests.patch b/dev-python/astunparse/files/astunparse-1.6.2-tests.patch
new file mode 100644
index 000000000000..b82c22831a9b
--- /dev/null
+++ b/dev-python/astunparse/files/astunparse-1.6.2-tests.patch
@@ -0,0 +1,23 @@
+diff --git a/tests/common.py b/tests/common.py
+index 95b9755..41123de 100644
+--- a/tests/common.py
++++ b/tests/common.py
+@@ -1,6 +1,7 @@
+ import codecs
+ import os
+ import sys
++import site
+ if sys.version_info < (2, 7):
+ import unittest2 as unittest
+ else:
+@@ -175,9 +176,7 @@ class AstunparseCommonTestCase:
+ def check_roundtrip(self, code1, filename="internal", mode="exec"):
+ raise NotImplementedError()
+
+- test_directories = [
+- os.path.join(getattr(sys, 'real_prefix', sys.prefix),
+- 'lib', 'python%s.%s' % sys.version_info[:2])]
++ test_directories = [os.path.dirname(d) for d in site.getsitepackages()]
+
+ def test_files(self):
+ names = []