Sync from SUSE:ALP:Source:Standard:1.0 python-astunparse revision 620b2036870b28074dafcb6ae26447e2

This commit is contained in:
Adrian Schröter 2023-06-07 08:26:07 +02:00
commit 4e320123f0
6 changed files with 257 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

BIN
astunparse-1.6.3.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,74 @@
From 0388a0d2f42401dcedf7f89d3c291cfed3e4a3d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
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?= <miro@hroncok.cz>
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 +-) removed from openSUSE patch for PyPI package
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',

23
fix-formatted-value.patch Normal file
View File

@ -0,0 +1,23 @@
From 3c661cb35b62268a553dd548a73178b5d7f708c7 Mon Sep 17 00:00:00 2001
From: Vincent Hellendoorn <vhellendoorn@live.nl>
Date: Tue, 29 Sep 2020 14:11:11 -0400
Subject: [PATCH] Use correct write call for FormattedValue
The unparser for formatted values incorrectly referred to `_fstring_JoinedStr`, which expects a `values` property that `FormattedValue`s don't have. This PR updates to the correct call.
---
lib/astunparse/unparser.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/astunparse/unparser.py b/lib/astunparse/unparser.py
index 0ef6fd8..7e8c1ca 100644
--- a/lib/astunparse/unparser.py
+++ b/lib/astunparse/unparser.py
@@ -482,7 +482,7 @@ def _FormattedValue(self, t):
# FormattedValue(expr value, int? conversion, expr? format_spec)
self.write("f")
string = StringIO()
- self._fstring_JoinedStr(t, string.write)
+ self._fstring_FormattedValue(t, string.write)
self.write(repr(string.getvalue()))
def _fstring_JoinedStr(self, t, write):

57
python-astunparse.changes Normal file
View File

@ -0,0 +1,57 @@
-------------------------------------------------------------------
Fri Apr 21 12:22:15 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 13 22:40:05 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Make calling of %{sle15modernpython} optional.
-------------------------------------------------------------------
Fri Feb 17 10:59:59 UTC 2023 - Dirk Müller <dmueller@suse.com>
- need to turn off noarch to be able to skip tests on 32bit arches
-------------------------------------------------------------------
Thu Feb 16 22:39:53 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add fix-formatted-value.patch
- skip tests on 32bit platforms
-------------------------------------------------------------------
Fri Sep 10 05:23:39 UTC 2021 - pgajdos@suse.com
- %check: use %pyunittest rpm macro
-------------------------------------------------------------------
Sun Apr 18 12:03:07 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Add astunparse-pr57-py39.patch by Fedora maintainer for Python
3.9 support -- gh#simonpercivall/astunparse#57
-------------------------------------------------------------------
Fri Jan 17 15:36:43 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- update to 1.6.3
* Add full support for Python 3.8
-------------------------------------------------------------------
Wed Mar 6 12:29:21 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 1.6.2:
* Python 3.7 compatibility
* Fix the roundtripping of very complex f-strings.
* Add support for the Constant node in Python 3.8
* Add tests to the sdist
- Execute tests
-------------------------------------------------------------------
Tue Dec 4 12:45:45 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Remove superfluous devel dependency for noarch package
-------------------------------------------------------------------
Fri Aug 3 03:33:04 UTC 2018 - toddrme2178@gmail.com
- Initial version

77
python-astunparse.spec Normal file
View File

@ -0,0 +1,77 @@
#
# spec file for package python-astunparse
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%{?sle15_python_module_pythons}
Name: python-astunparse
Version: 1.6.3
Release: 0
Summary: An AST unparser for Python
License: BSD-3-Clause AND Python-2.0
Group: Development/Languages/Python
URL: https://github.com/simonpercivall/astunparse
Source: https://files.pythonhosted.org/packages/source/a/astunparse/astunparse-%{version}.tar.gz
# PATCH-FIX-UPSTREAM astunparse-pr57-py39.patch -- gh#simonpercivall/astunparse#57
Patch0: astunparse-pr57-py39.patch
# https://github.com/simonpercivall/astunparse/pull/59
Patch1: fix-formatted-value.patch
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module six >= 1.6.1}
BuildRequires: %{python_module wheel >= 0.23.0}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-six >= 1.6.1
Requires: python-wheel >= 0.23.0
%python_subpackages
%description
This is a factored out version of ``unparse`` found in the Python
source distribution; under Demo/parser in Python 2 and under
Tools/parser in Python 3.
This library is single-source compatible with Python 2.6 through
Python 3.5. It is authored by the Python core developers; I have
simply merged the Python 2.7 and the Python 3.5 source and test
suites, and added a wrapper. This factoring out is to provide a
library implementation that supports both versions.
Added to this is a pretty-printing dump utility function.
%prep
%autosetup -p1 -n astunparse-%{version}
%build
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
# fails to parse the 32bit stdlib
%if "%_lib" == "lib64"
%check
%pyunittest discover -v
%endif
%files %{python_files}
%doc AUTHORS.rst README.rst HISTORY.rst
%license LICENSE
%{python_sitelib}/astunparse
%{python_sitelib}/astunparse-%{version}*-info
%changelog