diff --git a/Babel-2.11.0.tar.gz b/Babel-2.12.1.tar.gz similarity index 53% rename from Babel-2.11.0.tar.gz rename to Babel-2.12.1.tar.gz index 345f13ed1c58f1db99466d5d5450c855cd420d65..f0b34f8ea972e087025878817797148a02ff050c 100644 Binary files a/Babel-2.11.0.tar.gz and b/Babel-2.12.1.tar.gz differ diff --git a/babel.spec b/babel.spec index 245196c31c33d9d0f9b8a0a35e4f86373b06f3f0..7ac05a458be3ceccbbe4363f820a0be7be4b4367 100644 --- a/babel.spec +++ b/babel.spec @@ -1,13 +1,16 @@ %bcond_with bootstrap Name: babel -Version: 2.11.0 +Version: 2.12.1 Release: 1 Summary: Tools for internationalizing and localizing Python applications License: BSD URL: http://babel.pocoo.org/ Source0: https://files.pythonhosted.org/packages/source/B/Babel/Babel-%{version}.tar.gz +Patch6000: backport-Freeze-format_time-tests-to-a-specific-date-to-fix-t.patch +Patch6001: backport-Use-aware-UTC-datetimes-internally.patch + BuildArch: noarch BuildRequires: gcc make @@ -94,6 +97,12 @@ export TZ=UTC %endif %changelog +* Mon Aug 7 2023 zhoupengcheng - 2.12.1-1 +- update to 2.12.1 +- backport two patches from upstream to fix testcase failure after upgrade 2.12.1 + backport-Freeze-format_time-tests-to-a-specific-date-to-fix-t.patch + backport-Use-aware-UTC-datetimes-internally.patch + * Thu Jan 19 2023 zhangnan - 2.11.0-1 - update to 2.11.0 diff --git a/backport-Freeze-format_time-tests-to-a-specific-date-to-fix-t.patch b/backport-Freeze-format_time-tests-to-a-specific-date-to-fix-t.patch new file mode 100644 index 0000000000000000000000000000000000000000..ddfbb76aecccfef44225e3fd297ac1d04cfd6e0d --- /dev/null +++ b/backport-Freeze-format_time-tests-to-a-specific-date-to-fix-t.patch @@ -0,0 +1,41 @@ +From 8b152dbe47cb830f66ad12bd3057e6128aeac072 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= +Date: Tue, 9 May 2023 10:20:04 +0200 +Subject: [PATCH] Freeze format_time() tests to a specific date to fix test + failures (#998) + +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. +--- + 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 b94c710..3f1fc3f 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): +-- +2.27.0 + diff --git a/backport-Use-aware-UTC-datetimes-internally.patch b/backport-Use-aware-UTC-datetimes-internally.patch new file mode 100644 index 0000000000000000000000000000000000000000..40bb81310c3505fa11fa4c523774b2023c1e7bca --- /dev/null +++ b/backport-Use-aware-UTC-datetimes-internally.patch @@ -0,0 +1,97 @@ +From 1747d2230a0294a07c99563cf50fb95a37b6ac0f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ville=20Skytt=C3=A4?= +Date: Tue, 27 Jun 2023 23:08:06 +0300 +Subject: [PATCH] Use aware UTC datetimes internally (#1009) + +Avoids deprecation warnings on Python 3.12. +--- + babel/dates.py | 10 +++++----- + docs/dates.rst | 6 +++--- + tests/test_dates.py | 6 +++--- + 3 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/babel/dates.py b/babel/dates.py +index ad82b789b..ddc8e7105 100644 +--- a/babel/dates.py ++++ b/babel/dates.py +@@ -112,7 +112,7 @@ def _get_tz_name(dt_or_tzinfo: _DtOrTzinfo) -> str: + elif hasattr(tzinfo, 'key') and tzinfo.key is not None: # ZoneInfo object + return tzinfo.key + else: +- return tzinfo.tzname(dt or datetime.datetime.utcnow()) ++ return tzinfo.tzname(dt or datetime.datetime.now(UTC)) + + + def _get_datetime(instant: _Instant) -> datetime.datetime: +@@ -147,9 +147,9 @@ def _get_datetime(instant: _Instant) -> datetime.datetime: + :rtype: datetime + """ + if instant is None: +- return datetime.datetime.utcnow() ++ return datetime.datetime.now(UTC).replace(tzinfo=None) + elif isinstance(instant, (int, float)): +- return datetime.datetime.utcfromtimestamp(instant) ++ return datetime.datetime.fromtimestamp(instant, UTC).replace(tzinfo=None) + elif isinstance(instant, datetime.time): + return datetime.datetime.combine(datetime.date.today(), instant) + elif isinstance(instant, datetime.date) and not isinstance(instant, datetime.datetime): +@@ -201,9 +201,9 @@ def _get_time( + :rtype: time + """ + if time is None: +- time = datetime.datetime.utcnow() ++ time = datetime.datetime.now(UTC) + elif isinstance(time, (int, float)): +- time = datetime.datetime.utcfromtimestamp(time) ++ time = datetime.datetime.fromtimestamp(time, UTC) + + if time.tzinfo is None: + time = time.replace(tzinfo=UTC) +diff --git a/docs/dates.rst b/docs/dates.rst +index 1827a9a20..0c2c17fc0 100644 +--- a/docs/dates.rst ++++ b/docs/dates.rst +@@ -67,9 +67,9 @@ local time when returning dates to users. At that point the timezone the + user has selected can usually be established and Babel can automatically + rebase the time for you. + +-To get the current time use the :meth:`~datetime.datetime.utcnow` method +-of the :class:`~datetime.datetime` object. It will return a naive +-:class:`~datetime.datetime` object in UTC. ++To get the current time use the :meth:`~datetime.datetime.now` method ++of the :class:`~datetime.datetime` object, ++passing :attr:`~datetime.timezone.utc` to it as the timezone. + + For more information about timezones see :ref:`timezone-support`. + +diff --git a/tests/test_dates.py b/tests/test_dates.py +index 3f1fc3fc8..f4f577397 100644 +--- a/tests/test_dates.py ++++ b/tests/test_dates.py +@@ -17,7 +17,7 @@ + import pytest + + from babel import Locale, dates +-from babel.dates import NO_INHERITANCE_MARKER, _localize ++from babel.dates import NO_INHERITANCE_MARKER, UTC, _localize + from babel.util import FixedOffsetTimezone + + +@@ -542,7 +542,7 @@ def test_get_timezone_name_time_pytz(timezone_getter, tzname, params, expected): + + + def test_get_timezone_name_misc(timezone_getter): +- localnow = datetime.utcnow().replace(tzinfo=timezone_getter('UTC')).astimezone(dates.LOCALTZ) ++ localnow = datetime.now(timezone_getter('UTC')).astimezone(dates.LOCALTZ) + assert (dates.get_timezone_name(None, locale='en_US') == + dates.get_timezone_name(localnow, locale='en_US')) + +@@ -703,7 +703,7 @@ def test_zh_TW_format(): + + + def test_format_current_moment(): +- frozen_instant = datetime.utcnow() ++ frozen_instant = datetime.now(UTC) + with freezegun.freeze_time(time_to_freeze=frozen_instant): + assert dates.format_datetime(locale="en_US") == dates.format_datetime(frozen_instant, locale="en_US") +