[Python-modules-commits] [python-passlib] 03/03: Fix FTBFS due to integer overlow on testing

Brian May bam at moszumanska.debian.org
Sun Apr 23 01:47:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

bam pushed a commit to branch debian/stretch
in repository python-passlib.

commit af13b7df3c2e6695b28a75fc7ca326af58728ce6
Author: Brian May <bam at debian.org>
Date:   Sun Apr 23 08:19:33 2017 +1000

    Fix FTBFS due to integer overlow on testing
---
 debian/changelog                                   |  6 ++
 debian/patches/0001-Disable-Django-support.patch   |  1 -
 .../0002-Fix-max_time_t-overflow-error.patch       | 73 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 4 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 1c7cfee..25fbc6d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-passlib (1.7.0-2) testing-proposed-updates; urgency=medium
+
+  * Fix FTBFS with timestamp overlow overflow on i386. Closes: #860619.
+
+ -- Brian May <bam at debian.org>  Sun, 23 Apr 2017 08:16:49 +1000
+
 python-passlib (1.7.0-1) unstable; urgency=medium
 
   * Team upload.
diff --git a/debian/patches/0001-Disable-Django-support.patch b/debian/patches/0001-Disable-Django-support.patch
index 4906143..0014300 100644
--- a/debian/patches/0001-Disable-Django-support.patch
+++ b/debian/patches/0001-Disable-Django-support.patch
@@ -1,4 +1,3 @@
-From 9e5a4b32f8ff48670df80b7e97f88e3609ad6ca4 Mon Sep 17 00:00:00 2001
 From: Brian May <bam at debian.org>
 Date: Sun, 3 Jan 2016 14:37:23 +1100
 Subject: Disable Django support
diff --git a/debian/patches/0002-Fix-max_time_t-overflow-error.patch b/debian/patches/0002-Fix-max_time_t-overflow-error.patch
new file mode 100644
index 0000000..036f616
--- /dev/null
+++ b/debian/patches/0002-Fix-max_time_t-overflow-error.patch
@@ -0,0 +1,73 @@
+From: Brian May <bam at debian.org>
+Date: Sun, 23 Apr 2017 08:14:18 +1000
+Subject: Fix max_time_t overflow error
+
+Apply upstream patch from
+https://bitbucket.org/ecollins/passlib/commits/80f838f5771f6753b0e46716ab25b48641aeef89
+
+    passlib.tests.test_totp: fixed max_time_t calculation to trap some errors
+    it was errorneously letting through; also workaround for python 3.6 issue
+    29346.
+---
+ passlib/tests/test_totp.py | 48 +++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 39 insertions(+), 9 deletions(-)
+
+diff --git a/passlib/tests/test_totp.py b/passlib/tests/test_totp.py
+index 9af4d15..54a9d91 100644
+--- a/passlib/tests/test_totp.py
++++ b/passlib/tests/test_totp.py
+@@ -53,15 +53,45 @@ KEY4_RAW = b'Hello!\xde\xad\xbe\xef'
+ assert sys.float_info.radix == 2, "unexpected float_info.radix"
+ assert sys.float_info.mant_dig >= 44, "double precision unexpectedly small"
+ 
+-# work out maximum value acceptable by hosts's time_t
+-# this is frequently 2**37, though smaller on some systems.
+-max_time_t = 30
+-while True:
+-    try:
+-        datetime.datetime.utcfromtimestamp(max_time_t << 1)
+-        max_time_t <<= 1
+-    except ValueError:
+-        break
++def _get_max_time_t():
++    """
++    helper to calc max_time_t constant (see below)
++    """
++    value = 1 << 30  # even for 32 bit systems will handle this
++    year = 0
++    while True:
++        next_value = value << 1
++        try:
++            next_year = datetime.datetime.utcfromtimestamp(next_value-1).year
++        except (ValueError, OSError, OverflowError):
++            # utcfromtimestamp() may throw any of the following:
++            #
++            # * year out of range for datetime:
++            #   py < 3.6 throws ValueError.
++            #   (py 3.6.0 returns odd value instead, see workaround below)
++            #
++            # * int out of range for host's gmtime/localtime:
++            #   py2 throws ValueError, py3 throws OSError.
++            #
++            # * int out of range for host's time_t:
++            #   py2 throws ValueError, py3 throws OverflowError.
++            #
++            return value-1
++
++        # Workaround for python 3.6.0 issue --
++        # Instead of throwing ValueError if year out of range for datetime,
++        # Python 3.6 will do some weird behavior that masks high bits
++        # e.g. (1<<40) -> year 36812, but (1<<41) -> year 6118.
++        # (Filed as bug -- http://bugs.python.org/issue29346)
++        # This check stops at largest non-wrapping bit size.
++        if next_year < year:
++            return value-1
++
++        value = next_value
++
++#: Rough approximation of max value acceptable by hosts's time_t.
++#: This is frequently ~2**37 on 64 bit, and ~2**31 on 32 bit systems.
++max_time_t = _get_max_time_t()
+ 
+ def to_b32_size(raw_size):
+     return (raw_size * 8 + 4) // 5
diff --git a/debian/patches/series b/debian/patches/series
index 41967ef..b3f9f0c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-Disable-Django-support.patch
+0002-Fix-max_time_t-overflow-error.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-passlib.git



More information about the Python-modules-commits mailing list