diff --git a/astunparse-1.6.3.tar.gz b/astunparse-1.6.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..567f80e0b1158cefc5a4aa45ce3cd4ec2da4901d Binary files /dev/null and b/astunparse-1.6.3.tar.gz differ diff --git a/python-astunparse.spec b/python-astunparse.spec new file mode 100644 index 0000000000000000000000000000000000000000..6cb788731c86fa78c5859189e53ed879cd9b4a52 --- /dev/null +++ b/python-astunparse.spec @@ -0,0 +1,64 @@ +%define anolis_release 1 +%global pypi_name astunparse + +Name: python-%{pypi_name} +Version: 1.6.3 +Release: %{anolis_release}%{?dist} +Summary: An AST unparser for Python +License: BSD and Python +URL: https://github.com/simonpercivall/astunparse +Source0: %{pypi_source} + +# Python 3.9+ support +# https://github.com/simonpercivall/astunparse/pull/57 +Patch1: python3.9.patch + +BuildArch: noarch + +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-six +BuildRequires: python3-wheel + +%description +This is a factored out version of unparse found in the Python source +distribution; under Tools/parser in Python 3. + +%package -n python3-%{pypi_name} +Summary: %{summary} +%{?python_provide:%python_provide python3-%{pypi_name}} + +%description -n python3-%{pypi_name} +This is a factored out version of unparse found in the Python source +distribution; under Tools/parser in Python 3. + +%package -n python3-%{pypi_name}-doc +Summary: Doc files for python3-%{pypi_name} +Requires: python3-%{pypi_name} = %{EVR} + +%description -n python3-%{pypi_name}-doc +Doc files for python3-%{pypi_name} + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} + +%build +%py3_build + +%install +%py3_install + +%check +%{__python3} setup.py test + +%files -n python3-%{pypi_name} +%license LICENSE +%{python3_sitelib}/%{pypi_name}/ +%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info/ + +%files -n python3-%{pypi_name}-doc +%doc README.rst + +%changelog +* Wed Jun 14 2023 Chunmei Xu - 1.6.3-1 +- init from upstream diff --git a/python3.9.patch b/python3.9.patch new file mode 100644 index 0000000000000000000000000000000000000000..ab8116a559acdc1d5ec14b6237f490a0e9eed925 --- /dev/null +++ b/python3.9.patch @@ -0,0 +1,74 @@ +From 0388a0d2f42401dcedf7f89d3c291cfed3e4a3d5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Wed, 8 Jul 2020 20:15:57 +0200 +Subject: [PATCH 1/2] Adapt dump() behavior to match ast.dump() on Python 3.9+ + +In Python 3.9+, ast.dump() omits optional fields/attributes from the output if +their value is None. Such defaults are defined as class attributes. + +See https://bugs.python.org/issue36287 +And https://github.com/python/cpython/pull/18843 + +This patch does not change the output on previous Python versions, +because the class attributes are missing there. + +Fixes https://github.com/simonpercivall/astunparse/issues/56 +--- + lib/astunparse/printer.py | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/lib/astunparse/printer.py b/lib/astunparse/printer.py +index 92d64f7..7a33deb 100644 +--- a/lib/astunparse/printer.py ++++ b/lib/astunparse/printer.py +@@ -4,6 +4,9 @@ + import six + + ++_NOPE = object() ++ ++ + class Printer(ast.NodeVisitor): + + def __init__(self, file=sys.stdout, indent=" "): +@@ -19,6 +22,7 @@ def write(self, text): + self.f.write(six.text_type(text)) + + def generic_visit(self, node): ++ cls = type(node) + + if isinstance(node, list): + nodestart = "[" +@@ -27,7 +31,8 @@ def generic_visit(self, node): + else: + nodestart = type(node).__name__ + "(" + nodeend = ")" +- children = [(name + "=", value) for name, value in ast.iter_fields(node)] ++ children = [(name + "=", value) for name, value in ast.iter_fields(node) ++ if not (value is None and getattr(cls, name, _NOPE) is None)] + + if len(children) > 1: + self.indentation += 1 + +From ea2b578a1b653e73696db2392b8e3d5bf75dadc7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Wed, 8 Jul 2020 20:21:17 +0200 +Subject: [PATCH 2/2] Test and support Python 3.9 + +--- + setup.py | 1 + + tox.ini | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index e5a277a..29b384b 100755 +--- a/setup.py ++++ b/setup.py +@@ -52,6 +52,7 @@ def read_version(): + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', ++ 'Programming Language :: Python :: 3.9', + 'Topic :: Software Development :: Code Generators', + ], + test_suite='tests',