!30 update to 2.12.1 and fix the testcase failure after the upgrade
From: @zhoupengcheng11 Reviewed-by: @lvying6 Signed-off-by: @lvying6
This commit is contained in:
commit
6b01d44680
Binary file not shown.
11
babel.spec
11
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 <zhoupengcheng11@huawei.com> - 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 <zhangnan134@huawei.com> - 2.11.0-1
|
||||
- update to 2.11.0
|
||||
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
From 8b152dbe47cb830f66ad12bd3057e6128aeac072 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
||||
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
|
||||
|
||||
97
backport-Use-aware-UTC-datetimes-internally.patch
Normal file
97
backport-Use-aware-UTC-datetimes-internally.patch
Normal file
@ -0,0 +1,97 @@
|
||||
From 1747d2230a0294a07c99563cf50fb95a37b6ac0f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
|
||||
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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user