[thuban-Bugs][627] problem with sys.maxint on 64-bit machines

thuban-bugs@wald.intevation.org thuban-bugs at wald.intevation.org
Thu Jun 5 01:45:09 CEST 2008


Bugs item #627, was opened at 2008-06-04 20:45
Status: Open
Priority: 3
Submitted By: Anthony Lenton (elachuni)
Assigned to: Nobody (None)
Summary: problem with sys.maxint on 64-bit machines 
Resolution: None
Version: None
Category: None


Initial Comment:
wxpython checks against INT_MIN and INT_MAX (from glibc's limit.h) when validating int arguments, which on most 64-bit machines is still 2147483647 (0x7fffffff).

sys.maxint instead returns a full 64-bit integer, which then fails wxpython's validation.  So on 64-bit machines this code fails:

>>> import sys
>>> import wx
>>> app = wx.App()
>>> dialog = wx.Dialog(None)
>>> spin = wx.SpinCtrl(dialog)
>>> spin.SetRange (1, sys.maxint)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_controls.py",
line 2265, in SetRange
   return _controls_.SpinCtrl_SetRange(*args, **kwargs)
OverflowError: in method 'SpinCtrl_SetRange', expected argument 3 of type 'int'

This is used in thuban in Thuban/UI/classgen.py.  Effectively, if on a 64-bit machine you try to bring up the classification generation dialog, you get a traceback:

Traceback (most recent call last):
 File "/home/anthony/svn/thuban/trunk/thuban/Thuban/UI/classifier.py",
line 1057, in _OnGenClass
   internal_from_wxstring(self.fields.GetString(self.__cur_field)))
 File "/home/anthony/svn/thuban/trunk/thuban/Thuban/UI/classgen.py",
line 111, in __init__
   obj = clazz(self, self.layer, self.fieldName, self.fieldType)
 File "/home/anthony/svn/thuban/trunk/thuban/Thuban/UI/classgen.py",
line 412, in __init__
   self.numGroupsCtrl.SetRange(1, sys.maxint)
 File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_controls.py",
line 2265, in SetRange
   return _controls_.SpinCtrl_SetRange(*args, **kwargs)
OverflowError: in method 'SpinCtrl_SetRange', expected argument 3 of type 'int'

This patch fixes it, though it just hardcodes a 32-bit integer:

Index: Thuban/UI/classgen.py
===================================================================
--- Thuban/UI/classgen.py       (revisión: 2842)
+++ Thuban/UI/classgen.py       (copia de trabajo)
@@ -409,7 +409,7 @@
        self.numGroupsChanging = False
        self.steppingChanging = False

-        self.numGroupsCtrl.SetRange(1, sys.maxint)
+        self.numGroupsCtrl.SetRange(1, 2**31-1)

        self.numGroupsCtrl.SetValue(1)
        self.stepCtrl.SetValue("1")
@@ -832,7 +832,7 @@
                                        _("Retrieve from Table"))

        self.spin_numClasses = wx.SpinCtrl(self, -1, style=wx.TE_RIGHT)
-        self.spin_numClasses.SetRange(2, sys.maxint)
+        self.spin_numClasses.SetRange(2, 2**31-1)
        self.spin_numClasses.SetValue(2)



----------------------------------------------------------------------

You can respond by visiting: 
http://wald.intevation.org/tracker/?func=detail&atid=105&aid=627&group_id=6




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)