Ivo De Decker <iv...@debian.org> writes:

> I prefer to fix this via t-p-u, as it's only a change to the tests. Please go
> ahead and upload to t-p-u with the patch above and remove the moreinfo tag
> from this bug once the package is uploaded.

Done. Attached is a debdiff.

diff -Nru python-passlib-1.7.0/debian/changelog 
python-passlib-1.7.0/debian/changelog
--- python-passlib-1.7.0/debian/changelog       2016-11-29 03:31:28.000000000 
+1100
+++ python-passlib-1.7.0/debian/changelog       2017-04-23 08:16:49.000000000 
+1000
@@ -1,3 +1,9 @@
+python-passlib (1.7.0-2) testing-proposed-updates; urgency=medium
+
+  * Fix FTBFS with timestampe overlow overflow on i386. Closes: #860619.
+
+ -- Brian May <b...@debian.org>  Sun, 23 Apr 2017 08:16:49 +1000
+
 python-passlib (1.7.0-1) unstable; urgency=medium
 
   * Team upload.
diff -Nru python-passlib-1.7.0/debian/gbp.conf 
python-passlib-1.7.0/debian/gbp.conf
--- python-passlib-1.7.0/debian/gbp.conf        2016-01-03 14:37:52.000000000 
+1100
+++ python-passlib-1.7.0/debian/gbp.conf        2017-04-23 08:02:39.000000000 
+1000
@@ -1,2 +1,2 @@
 [DEFAULT]
-debian-branch = master
+debian-branch = debian/stretch
diff -Nru python-passlib-1.7.0/debian/.git-dpm 
python-passlib-1.7.0/debian/.git-dpm
--- python-passlib-1.7.0/debian/.git-dpm        2016-11-29 03:31:28.000000000 
+1100
+++ python-passlib-1.7.0/debian/.git-dpm        1970-01-01 10:00:00.000000000 
+1000
@@ -1,11 +0,0 @@
-# see git-dpm(1) from git-dpm package
-9e5a4b32f8ff48670df80b7e97f88e3609ad6ca4
-9e5a4b32f8ff48670df80b7e97f88e3609ad6ca4
-4f8eb9d90fdaa143465e40bef41fd151466854dc
-4f8eb9d90fdaa143465e40bef41fd151466854dc
-python-passlib_1.7.0.orig.tar.gz
-a773592d9675c41465bd47c12f447e1100611703
-637909
-debianTag="debian/%e%v"
-patchedTag="patched/%e%v"
-upstreamTag="upstream/%e%u"
diff -Nru python-passlib-1.7.0/debian/patches/0001-Disable-Django-support.patch 
python-passlib-1.7.0/debian/patches/0001-Disable-Django-support.patch
--- python-passlib-1.7.0/debian/patches/0001-Disable-Django-support.patch       
2016-11-29 03:31:28.000000000 +1100
+++ python-passlib-1.7.0/debian/patches/0001-Disable-Django-support.patch       
2017-04-23 08:16:24.000000000 +1000
@@ -1,4 +1,3 @@
-From 9e5a4b32f8ff48670df80b7e97f88e3609ad6ca4 Mon Sep 17 00:00:00 2001
 From: Brian May <b...@debian.org>
 Date: Sun, 3 Jan 2016 14:37:23 +1100
 Subject: Disable Django support
diff -Nru 
python-passlib-1.7.0/debian/patches/0002-Fix-max_time_t-overflow-error.patch 
python-passlib-1.7.0/debian/patches/0002-Fix-max_time_t-overflow-error.patch
--- 
python-passlib-1.7.0/debian/patches/0002-Fix-max_time_t-overflow-error.patch    
    1970-01-01 10:00:00.000000000 +1000
+++ 
python-passlib-1.7.0/debian/patches/0002-Fix-max_time_t-overflow-error.patch    
    2017-04-23 08:16:24.000000000 +1000
@@ -0,0 +1,73 @@
+From: Brian May <b...@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 -Nru python-passlib-1.7.0/debian/patches/series 
python-passlib-1.7.0/debian/patches/series
--- python-passlib-1.7.0/debian/patches/series  2016-11-29 03:31:28.000000000 
+1100
+++ python-passlib-1.7.0/debian/patches/series  2017-04-23 08:16:24.000000000 
+1000
@@ -1 +1,2 @@
 0001-Disable-Django-support.patch
+0002-Fix-max_time_t-overflow-error.patch

-- 
Brian May <b...@debian.org>

Reply via email to