From dcb64b2067c0ff5d011b53a1da54fe9fed0177e3ff0872069216f0bc723e0fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Fri, 15 Mar 2024 14:46:34 +0000 Subject: [PATCH] Accepting request 1158173 from home:mcalabkova:branches:devel:languages:python - Add patch utc.patch to fix the behavior on Python 3.12 OBS-URL: https://build.opensuse.org/request/show/1158173 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-pptx?expand=0&rev=9 --- python-python-pptx.changes | 5 +++ python-python-pptx.spec | 7 +-- utc.patch | 88 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 utc.patch diff --git a/python-python-pptx.changes b/python-python-pptx.changes index 959380c..fb486c5 100644 --- a/python-python-pptx.changes +++ b/python-python-pptx.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Mar 15 09:18:12 UTC 2024 - Markéta Machová + +- Add patch utc.patch to fix the behavior on Python 3.12 + ------------------------------------------------------------------- Tue Dec 26 20:29:02 UTC 2023 - Dirk Müller diff --git a/python-python-pptx.spec b/python-python-pptx.spec index eaa23d2..2f48310 100644 --- a/python-python-pptx.spec +++ b/python-python-pptx.spec @@ -1,7 +1,7 @@ # # spec file for package python-python-pptx # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # Copyright (c) 2021, Martin Hauke # # All modifications and additions to the file contributed by third parties @@ -17,7 +17,6 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-python-pptx Version: 0.6.23 Release: 0 @@ -25,6 +24,8 @@ Summary: Generate and manipulate Open XML PowerPoint (pptx) files License: MIT URL: http://github.com/scanny/python-pptx Source: https://files.pythonhosted.org/packages/source/p/python-pptx/python-pptx-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/scanny/python-pptx/pull/957 Use UTC-aware datetime objects +Patch: utc.patch BuildRequires: %{python_module setuptools} BuildRequires: python-rpm-macros # SECTION test requirements @@ -46,7 +47,7 @@ BuildArch: noarch Generate and manipulate Open XML PowerPoint (.pptx) files. %prep -%setup -q -n python-pptx-%{version} +%autosetup -p1 -n python-pptx-%{version} %build %python_build diff --git a/utc.patch b/utc.patch new file mode 100644 index 0000000..557efc5 --- /dev/null +++ b/utc.patch @@ -0,0 +1,88 @@ +Index: python-pptx-0.6.23/features/steps/coreprops.py +=================================================================== +--- python-pptx-0.6.23.orig/features/steps/coreprops.py ++++ python-pptx-0.6.23/features/steps/coreprops.py +@@ -6,7 +6,7 @@ Gherkin step implementations for core pr + + from __future__ import absolute_import + +-from datetime import datetime, timedelta ++from datetime import datetime, timedelta, timezone + + from behave import given, when, then + +@@ -67,7 +67,7 @@ def step_then_a_core_props_part_with_def + assert core_props.revision == 1 + # core_props.modified only stores time with seconds resolution, so + # comparison needs to be a little loose (within two seconds) +- modified_timedelta = datetime.utcnow() - core_props.modified ++ modified_timedelta = datetime.now(timezone.utc) - core_props.modified + max_expected_timedelta = timedelta(seconds=2) + assert modified_timedelta < max_expected_timedelta + +Index: python-pptx-0.6.23/pptx/parts/coreprops.py +=================================================================== +--- python-pptx-0.6.23.orig/pptx/parts/coreprops.py ++++ python-pptx-0.6.23/pptx/parts/coreprops.py +@@ -2,7 +2,7 @@ + + """Core properties part, corresponds to ``/docProps/core.xml`` part in package.""" + +-from datetime import datetime ++from datetime import datetime, timezone + + from pptx.opc.constants import CONTENT_TYPE as CT + from pptx.opc.package import XmlPart +@@ -27,7 +27,7 @@ class CorePropertiesPart(XmlPart): + core_props.title = "PowerPoint Presentation" + core_props.last_modified_by = "python-pptx" + core_props.revision = 1 +- core_props.modified = datetime.utcnow() ++ core_props.modified = datetime.now(timezone.utc) + return core_props + + @property +Index: python-pptx-0.6.23/tests/parts/test_coreprops.py +=================================================================== +--- python-pptx-0.6.23.orig/tests/parts/test_coreprops.py ++++ python-pptx-0.6.23/tests/parts/test_coreprops.py +@@ -4,7 +4,7 @@ + + import pytest + +-from datetime import datetime, timedelta ++from datetime import datetime, timedelta, timezone + + from pptx.opc.constants import CONTENT_TYPE as CT + from pptx.oxml.coreprops import CT_CoreProperties +@@ -55,7 +55,7 @@ class DescribeCorePropertiesPart(object) + assert core_props.revision == 1 + # core_props.modified only stores time with seconds resolution, so + # comparison needs to be a little loose (within two seconds) +- modified_timedelta = datetime.utcnow() - core_props.modified ++ modified_timedelta = datetime.now(timezone.utc) - core_props.modified + max_expected_timedelta = timedelta(seconds=2) + assert modified_timedelta < max_expected_timedelta + +@@ -70,7 +70,7 @@ class DescribeCorePropertiesPart(object) + ) + def date_prop_get_fixture(self, request, core_properties): + prop_name, expected_datetime = request.param +- return core_properties, prop_name, expected_datetime ++ return core_properties, prop_name, expected_datetime.astimezone() if expected_datetime is not None else None + + @pytest.fixture( + params=[ +Index: python-pptx-0.6.23/pptx/oxml/coreprops.py +=================================================================== +--- python-pptx-0.6.23.orig/pptx/oxml/coreprops.py ++++ python-pptx-0.6.23/pptx/oxml/coreprops.py +@@ -247,7 +247,7 @@ class CT_CoreProperties(BaseOxmlElement) + dt = None + for tmpl in templates: + try: +- dt = datetime.strptime(parseable_part, tmpl) ++ dt = datetime.strptime(parseable_part, tmpl).astimezone() + except ValueError: + continue + if dt is None: