Backport the replacement for deprecated dateutil.dateutil.utcfromtimestamp()

In Python 3.12 it emits warnings that sometimes cause problems (eg. failing
test suites treating warning as errors) in packages depending on this package.
This commit is contained in:
Karolina Surma 2023-07-04 12:39:35 +02:00
parent b1ef771499
commit a79646c562
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,23 @@
From f2293200747fb03d56c6c5997bfebeabe703576f Mon Sep 17 00:00:00 2001
From: Thomas Grainger <tagrain@gmail.com>
Date: Fri, 2 Jun 2023 14:06:41 +0100
Subject: [PATCH] avoid deprecated utcfromtimestamp
Fixes #1284
---
src/dateutil/tz/tz.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dateutil/tz/tz.py b/src/dateutil/tz/tz.py
index c67f56d46..617591446 100644
--- a/src/dateutil/tz/tz.py
+++ b/src/dateutil/tz/tz.py
@@ -34,7 +34,7 @@
from warnings import warn
ZERO = datetime.timedelta(0)
-EPOCH = datetime.datetime.utcfromtimestamp(0)
+EPOCH = datetime.datetime(1970, 1, 1, 0, 0)
EPOCHORDINAL = EPOCH.toordinal()

View File

@ -2,7 +2,7 @@
Name: python-%{modname} Name: python-%{modname}
Version: 2.8.2 Version: 2.8.2
Release: 8%{?dist} Release: 9%{?dist}
Epoch: 1 Epoch: 1
Summary: Powerful extensions to the standard datetime module Summary: Powerful extensions to the standard datetime module
@ -22,6 +22,10 @@ Source: %{pypi_source}
# https://bugzilla.redhat.com/show_bug.cgi?id=2059950 # https://bugzilla.redhat.com/show_bug.cgi?id=2059950
Patch1: %{url}/commit/2bdd63158b7f981fc6d70a869680451bdfd8d848.patch Patch1: %{url}/commit/2bdd63158b7f981fc6d70a869680451bdfd8d848.patch
# Backport the replacement for the deprecated in Python 3.12
# datetime.datetime.utcfromtimestamp()
Patch2: %{url}/commit/f2293200747fb03d56c6c5997bfebeabe703576f.patch
# when bootstrapping dateutil-freezegun, we cannot run tests # when bootstrapping dateutil-freezegun, we cannot run tests
# on RHEL, we do not have or want all test dependencies # on RHEL, we do not have or want all test dependencies
%bcond tests %{undefined rhel} %bcond tests %{undefined rhel}
@ -66,6 +70,7 @@ This package contains %{summary}.
pushd %{modname}/test pushd %{modname}/test
%patch1 -p2 %patch1 -p2
popd popd
%patch2 -p2
iconv --from=ISO-8859-1 --to=UTF-8 NEWS > NEWS.new iconv --from=ISO-8859-1 --to=UTF-8 NEWS > NEWS.new
mv NEWS.new NEWS mv NEWS.new NEWS
@ -94,6 +99,9 @@ make -C docs html
%doc docs/_build/html %doc docs/_build/html
%changelog %changelog
* Tue Jul 04 2023 Karolina Surma <ksurma@redhat.com> - 1:2.8.2-9
- Backport replacement for deprecated datetime.datetime.utcfromtimestamp()
* Fri Jun 16 2023 Python Maint <python-maint@redhat.com> - 1:2.8.2-8 * Fri Jun 16 2023 Python Maint <python-maint@redhat.com> - 1:2.8.2-8
- Rebuilt for Python 3.12 - Rebuilt for Python 3.12