Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-astor for openSUSE:Factory checked in at 2025-09-11 14:38:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-astor (Old) and /work/SRC/openSUSE:Factory/.python-astor.new.1977 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-astor" Thu Sep 11 14:38:06 2025 rev:17 rq:1303552 version:0.8.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-astor/python-astor.changes 2025-06-13 18:43:49.338866714 +0200 +++ /work/SRC/openSUSE:Factory/.python-astor.new.1977/python-astor.changes 2025-09-11 14:39:05.891181688 +0200 @@ -1,0 +2,5 @@ +Mon Sep 8 12:44:02 UTC 2025 - Markéta Machová <[email protected]> + +- Add py314.patch to support Python 3.14 + +------------------------------------------------------------------- New: ---- py314.patch ----------(New B)---------- New: - Add py314.patch to support Python 3.14 ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-astor.spec ++++++ --- /var/tmp/diff_new_pack.LGJsOP/_old 2025-09-11 14:39:06.439204864 +0200 +++ /var/tmp/diff_new_pack.LGJsOP/_new 2025-09-11 14:39:06.443205034 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-astor # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2025 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -30,6 +30,8 @@ # https://github.com/berkerpeksag/astor/commit/8342d6aa5dcdcf20f89a19057527510c245c7a2e Patch1: lower-huge-int.patch Patch2: support-match.patch +# PATCH-FIX-UPSTREAM https://github.com/berkerpeksag/astor/pull/233 Fix compatibility with Python 3.14 (mostly) +Patch3: py314.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel} @@ -38,10 +40,6 @@ BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module pytest} -%if %{with python2} -# The tests use it internally, even when called from pytest-2 -BuildRequires: python-unittest2 -%endif # /SECTION %python_subpackages ++++++ py314.patch ++++++ >From d0b5563cc1e263f08df9312d89a7691167448f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> Date: Wed, 14 May 2025 19:52:30 +0200 Subject: [PATCH] Fix compatibility with Python 3.14 (mostly) Fix the code and the test suite to work with Python 3.14, where deprecated constant-like AST nodes were removed. Notably: 1. Skip tests for deprecated nodes in Python 3.14. 2. Use `ast.Constant` over `ast.Num` for non-deprecated code in Python 3.6+. 3. Check for `ast.Str` only in Python < 3.14, and handle `ast.Constant` being used to represent a string instead. With these changes, all tests except for: tests/test_rtrip.py::RtripTestCase::test_convert_stdlib pass. However, this particular test also hanged for me with older Python versions. Related to #217 --- astor/code_gen.py | 9 +++++++-- tests/test_code_gen.py | 11 ++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/astor/code_gen.py b/astor/code_gen.py index b2bae12..4330f49 100644 --- a/astor/code_gen.py +++ b/astor/code_gen.py @@ -692,6 +692,7 @@ def _handle_string_constant(self, node, value, is_joined=False): current_line = ''.join(current_line) has_ast_constant = sys.version_info >= (3, 6) + has_ast_str = sys.version_info < (3, 14) if is_joined: # Handle new f-strings. This is a bit complicated, because @@ -700,7 +701,7 @@ def _handle_string_constant(self, node, value, is_joined=False): def recurse(node): for value in node.values: - if isinstance(value, ast.Str): + if has_ast_str and isinstance(value, ast.Str): # Double up braces to escape them. self.write(value.s.replace('{', '{{').replace('}', '}}')) elif isinstance(value, ast.FormattedValue): @@ -713,7 +714,11 @@ def recurse(node): self.write(':') recurse(value.format_spec) elif has_ast_constant and isinstance(value, ast.Constant): - self.write(value.value) + if isinstance(value.value, str): + # Double up braces to escape them. + self.write(value.value.replace('{', '{{').replace('}', '}}')) + else: + self.write(value.value) else: kind = type(value).__name__ assert False, 'Invalid node %s inside JoinedStr' % kind diff --git a/tests/test_code_gen.py b/tests/test_code_gen.py index e828eb9..1825030 100644 --- a/tests/test_code_gen.py +++ b/tests/test_code_gen.py @@ -28,7 +28,10 @@ def astorexpr(x): return eval(astor.to_source(ast.Expression(body=x))) def astornum(x): - return astorexpr(ast.Num(n=x)) + if sys.version_info >= (3, 6): + return astorexpr(ast.Constant(x)) + else: + return astorexpr(ast.Num(n=x)) class Comparisons(object): @@ -515,8 +518,8 @@ def test_deprecated_constants_as_name(self): ast.Assign(targets=[ast.Name(id='spam')], value=ast.Name(id='None')), "spam = None") - @unittest.skipUnless(sys.version_info >= (3, 4), - "ast.NameConstant introduced in Python 3.4") + @unittest.skipUnless((3, 4) <= sys.version_info < (3, 14), + "ast.NameConstant introduced in Python 3.4, removed in 3.14") def test_deprecated_name_constants(self): self.assertAstEqualsSource( ast.Assign(targets=[ast.Name(id='spam')], value=ast.NameConstant(value=True)), @@ -530,6 +533,8 @@ def test_deprecated_name_constants(self): ast.Assign(targets=[ast.Name(id='spam')], value=ast.NameConstant(value=None)), "spam = None") + @unittest.skipIf(sys.version_info >= (3, 14), + "Deprecated Constant nodes removed in Python 3.14") def test_deprecated_constant_nodes(self): self.assertAstEqualsSource( ast.Assign(targets=[ast.Name(id='spam')], value=ast.Num(3)),
