#4 Fix builtin and extension functions that takes integer arguments
Merged 10 months ago by churchyard. Opened a year ago by thrnciar.
rpms/ thrnciar/python-isodate fix-decimal-object  into  rawhide

@@ -0,0 +1,67 @@ 

+ From 03e2d16f3306e3450da0e69ae47c427d715457a9 Mon Sep 17 00:00:00 2001

+ From: Tomas Hrnciar <thrnciar@redhat.com>

+ Date: Fri, 30 Oct 2020 10:01:24 +0100

+ Subject: [PATCH]  Fix interpret decimal.Decimal object as an integer

+ 

+ Ref: https://docs.python.org/3.8/whatsnew/3.8.html

+ 

+ Many builtin and extension functions that take integer arguments will

+ now emit a deprecation warning for Decimals, Fractions and any other

+ objects that can be converted to integers only with a loss (e.g. that

+ have the `__int__()` method but do not have the `__index__()` method).

+ In future version they will be errors. (Contributed by Serhiy

+ Storchaka in bpo-36048.)

+ 

+ ---

+  src/isodate/duration.py       | 6 ++++--

+  src/isodate/tests/__init__.py | 3 +++

+  2 files changed, 7 insertions(+), 2 deletions(-)

+ 

+ diff --git a/src/isodate/duration.py b/src/isodate/duration.py

+ index 6d1848c..96127ab 100644

+ --- a/src/isodate/duration.py

+ +++ b/src/isodate/duration.py

+ @@ -180,7 +180,8 @@ class Duration(object):

+                  newday = maxdays

+              else:

+                  newday = other.day

+ -            newdt = other.replace(year=newyear, month=newmonth, day=newday)

+ +            newdt = other.replace(

+ +                year=int(newyear), month=int(newmonth), day=newday)

+              # does a timedelta + date/datetime

+              return self.tdelta + newdt

+          except AttributeError:

+ @@ -264,7 +265,8 @@ class Duration(object):

+                  newday = maxdays

+              else:

+                  newday = other.day

+ -            newdt = other.replace(year=newyear, month=newmonth, day=newday)

+ +            newdt = other.replace(

+ +                year=int(newyear), month=int(newmonth), day=newday)

+              return newdt - self.tdelta

+          except AttributeError:

+              # other probably was not compatible with data/datetime

+ diff --git a/src/isodate/tests/__init__.py b/src/isodate/tests/__init__.py

+ index b1d46bd..7208cbd 100644

+ --- a/src/isodate/tests/__init__.py

+ +++ b/src/isodate/tests/__init__.py

+ @@ -29,6 +29,7 @@ Collect all test suites into one TestSuite instance.

+  '''

+  

+  import unittest

+ +import warnings

+  from isodate.tests import (test_date, test_time, test_datetime, test_duration,

+                             test_strf, test_pickle)

+  

+ @@ -37,6 +38,8 @@ def test_suite():

+      '''

+      Return a new TestSuite instance consisting of all available TestSuites.

+      '''

+ +    warnings.filterwarnings("error", module=r"isodate(\..)*")

+ +

+      return unittest.TestSuite([

+          test_date.test_suite(),

+          test_time.test_suite(),

+ -- 

+ 2.26.2

+ 

file modified
+5 -1
@@ -7,6 +7,10 @@ 

  License:        BSD

  URL:            https://pypi.org/project/isodate/

  Source0:        %pypi_source

+ # Python3.10 cannot interpret decimal.Decimal object as an integer.

+ # This patch fixes it until PR is not merged in upstream.

+ # https://github.com/gweis/isodate/issues/58

+ Patch1:		0001-Fix-interpret-decimal-object-as-an-integer.patch

  BuildArch:      noarch

  

  BuildRequires:  python3-devel
@@ -45,7 +49,7 @@ 

  

  

  %prep

- %autosetup -n %{srcname}-%{version}

+ %autosetup -n %{srcname}-%{version} -p1

  

  

  %build

Ref: https://docs.python.org/3.10/whatsnew/3.10.html

Many builtin and extension functions that take integer arguments throws
error for Decimals, Fractions and any other objects that can be
converted to integers only with a loss (e.g. that
have the __int__() method but do not have the __index__() method).

rebased onto 479bae6

a year ago

This was ack'd here, so I am merging it.
EDIT: Or not, missing privileges to do so. :)

rebased onto fc57cd4

10 months ago

Pull-Request has been merged by churchyard

10 months ago