[python-hdf5storage] 53/84: Fixed bug on 32-bit Python 2.x with determining the maximum int size.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:25:03 UTC 2016


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

ghisvail-guest pushed a commit to annotated tag 0.1.10
in repository python-hdf5storage.

commit 8b2f9aef35a718a0e734de65854d9a10faaeff50
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Tue Jul 7 00:08:42 2015 -0400

    Fixed bug on 32-bit Python 2.x with determining the maximum int size.
---
 hdf5storage/Marshallers.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hdf5storage/Marshallers.py b/hdf5storage/Marshallers.py
index 56f0e61..8a5820c 100644
--- a/hdf5storage/Marshallers.py
+++ b/hdf5storage/Marshallers.py
@@ -1322,10 +1322,12 @@ class PythonScalarMarshaller(NumpyScalarArrayMarshaller):
         # from if not given the right one explicitly.
         if sys.hexversion >= 0x03000000:
             tp = int
+            maxint = 2**63
         else:
             tp = long
+            maxint = sys.maxint
         if type(data) == tp:
-            if data > 2**63 or data < -(2**63) + 1:
+            if data > maxint or data < -(maxint - 1):
                 raise NotImplementedError('Int/long too big to fit ' \
                     + 'into numpy.int64.')
             else:
@@ -1361,7 +1363,7 @@ class PythonScalarMarshaller(NumpyScalarArrayMarshaller):
                 return tp(sdata)
             else:
                 num = long(sdata)
-                if num > sys.maxint or num < (-sys.maxint + 1):
+                if num > sys.maxint or num < -(sys.maxint - 1):
                     return num
                 else:
                     return int(num)

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



More information about the debian-science-commits mailing list