diff --git a/1027.patch b/1027.patch deleted file mode 100644 index 2c4bc2a..0000000 --- a/1027.patch +++ /dev/null @@ -1,89 +0,0 @@ -From be26d03a477a8c7a3919e2ba00121a0f7954bdb5 Mon Sep 17 00:00:00 2001 -From: Petr Viktorin -Date: Thu, 21 Sep 2023 12:45:32 +0200 -Subject: [PATCH] Add F f-string parsing for Python 3.12 (PEP 701) - -Since Python 3.12, f-strings are tokenized and parsed like the rest -of Python's grammar, using the new tokens FSTRING_START, FSTRING_MIDDLE -and FSTRING_END. - -Make the babel message extractor concatenate these three if they're -adjacent to each other. If they're not, that means there are dynamic -substitutions, so the f-string is ignored. ---- - babel/messages/extract.py | 34 ++++++++++++++++++++++++++++++++++ - 1 file changed, 34 insertions(+) - -diff --git a/babel/messages/extract.py b/babel/messages/extract.py -index b6dce6fd..5b67d2b7 100644 ---- a/babel/messages/extract.py -+++ b/babel/messages/extract.py -@@ -33,6 +33,7 @@ - from textwrap import dedent - from tokenize import COMMENT, NAME, OP, STRING, generate_tokens - from typing import TYPE_CHECKING, Any -+import tokenize - - from babel.util import parse_encoding, parse_future_flags, pathmatch - -@@ -89,6 +90,11 @@ def tell(self) -> int: ... - - DEFAULT_MAPPING: list[tuple[str, str]] = [('**.py', 'python')] - -+# New tokens in Python 3.12, or None on older versions -+FSTRING_START = getattr(tokenize, "FSTRING_START", None) -+FSTRING_MIDDLE = getattr(tokenize, "FSTRING_MIDDLE", None) -+FSTRING_END = getattr(tokenize, "FSTRING_END", None) -+ - - def _strip_comment_tags(comments: MutableSequence[str], tags: Iterable[str]): - """Helper function for `extract` that strips comment tags from strings -@@ -497,6 +503,11 @@ def extract_python( - next_line = lambda: fileobj.readline().decode(encoding) - - tokens = generate_tokens(next_line) -+ -+ # Current prefix of a Python 3.12 (PEP 701) f-string, or None if we're not -+ # currently parsing one. -+ current_fstring_start = None -+ - for tok, value, (lineno, _), _, _ in tokens: - if call_stack == -1 and tok == NAME and value in ('def', 'class'): - in_def = True -@@ -558,6 +569,20 @@ def extract_python( - val = _parse_python_string(value, encoding, future_flags) - if val is not None: - buf.append(val) -+ -+ # Python 3.12+, see https://peps.python.org/pep-0701/#new-tokens -+ elif tok == FSTRING_START: -+ current_fstring_start = value -+ elif tok == FSTRING_MIDDLE: -+ if current_fstring_start is not None: -+ current_fstring_start += value -+ elif tok == FSTRING_END: -+ if current_fstring_start is not None: -+ fstring = current_fstring_start + value -+ val = _parse_python_string(fstring, encoding, future_flags) -+ if val is not None: -+ buf.append(val) -+ - elif tok == OP and value == ',': - if buf: - messages.append(''.join(buf)) -@@ -578,6 +603,15 @@ def extract_python( - elif tok == NAME and value in keywords: - funcname = value - -+ if (current_fstring_start is not None -+ and tok not in {FSTRING_START, FSTRING_MIDDLE} -+ ): -+ # In Python 3.12, tokens other than FSTRING_* mean the -+ # f-string is dynamic, so we don't wan't to extract it. -+ # And if it's FSTRING_END, we've already handled it above. -+ # Let's forget that we're in an f-string. -+ current_fstring_start = None -+ - - def _parse_python_string(value: str, encoding: str, future_flags: int) -> str | None: - # Unwrap quotes in a safe manner, maintaining the string's encoding diff --git a/998.patch b/998.patch deleted file mode 100644 index 4779f90..0000000 --- a/998.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 641f58c9951d9f5746cd63743dd337f1340d7bff Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= -Date: Fri, 7 Apr 2023 14:51:10 +0000 -Subject: [PATCH] Freeze format_time() tests to a specific date to fix test - failures - -Freeze the date when performing the tests for format_time() with -a timezone specified. Since the time object does not specify a date, -the formatter uses the format string specific to the current date. -As a result, if the current DST state is different than when the test -was last updated, it failed. - -This fix covers only regular tests. I have no idea how to do the same -for doctests. - -Issue #988 ---- - tests/test_dates.py | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) - -diff --git a/tests/test_dates.py b/tests/test_dates.py -index b94c710f..3f1fc3fc 100644 ---- a/tests/test_dates.py -+++ b/tests/test_dates.py -@@ -601,12 +601,13 @@ def test_format_time(timezone_getter): - custom = dates.format_time(t, "hh 'o''clock' a, zzzz", tzinfo=eastern, locale='en') - assert custom == "09 o'clock AM, Eastern Daylight Time" - -- t = time(15, 30) -- paris = dates.format_time(t, format='full', tzinfo=paris, locale='fr_FR') -- assert paris == '15:30:00 heure normale d’Europe centrale' -+ with freezegun.freeze_time("2023-01-01"): -+ t = time(15, 30) -+ paris = dates.format_time(t, format='full', tzinfo=paris, locale='fr_FR') -+ assert paris == '15:30:00 heure normale d’Europe centrale' - -- us_east = dates.format_time(t, format='full', tzinfo=eastern, locale='en_US') -- assert us_east == '3:30:00\u202fPM Eastern Standard Time' -+ us_east = dates.format_time(t, format='full', tzinfo=eastern, locale='en_US') -+ assert us_east == '3:30:00\u202fPM Eastern Standard Time' - - - def test_format_skeleton(timezone_getter): diff --git a/babel.spec b/babel.spec index 8f7207f..659272e 100644 --- a/babel.spec +++ b/babel.spec @@ -15,22 +15,14 @@ %bcond datetime_tests %{undefined rhel} Name: babel -Version: 2.12.1 -Release: 6%{?dist} +Version: 2.13.1 +Release: 1%{?dist} Summary: Tools for internationalizing Python applications License: BSD-3-Clause URL: https://babel.pocoo.org/ Source: %{pypi_source Babel} -# Freeze format_time() tests to a specific date to fix test failures -# Partially fixes https://bugzilla.redhat.com/2179515 -# 2 doctests are still deselected (as doctests are not part of this fix) -Patch: https://github.com/python-babel/babel/pull/998.patch - -# New code for extracting f-strings for Pytohn 3.12 (PEP 701) -Patch: https://github.com/python-babel/babel/pull/1027.patch - BuildArch: noarch BuildRequires: python3-devel diff --git a/sources b/sources index 46590d0..82c8952 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (Babel-2.12.1.tar.gz) = 93c4bf343d99a1f47f43f8b828eb79098cb429bac1034d58b5aa49adff68116e458067f3784d997f34515828a7432fd18f7abbaeee59b47a4ee8ea744908b33b +SHA512 (Babel-2.13.1.tar.gz) = c27c76456094927bd43ae46cd3e08fcc729dd810a6092da6c86e863523c10746bb3759e7fc9f5396504ab914743ef013904b63b3aa63338602f23aaf83d42cba