[Zodb-checkins] SVN: ZODB/trunk/src/ Bug fixed:

Jim Fulton jim at zope.com
Thu Jul 15 12:53:12 EDT 2010


Log message for revision 114787:
  Bug fixed:
  
  When an integer too large to fit in a 32-bit integer was provided as
    a 32-bit-integer BTree key or value on 64-bit machines, an
    OverflowError was raised. Now a TypeError is raised.
  

Changed:
  U   ZODB/trunk/src/BTrees/intkeymacros.h
  U   ZODB/trunk/src/BTrees/intvaluemacros.h
  U   ZODB/trunk/src/BTrees/tests/testBTrees.py
  U   ZODB/trunk/src/CHANGES.txt

-=-
Modified: ZODB/trunk/src/BTrees/intkeymacros.h
===================================================================
--- ZODB/trunk/src/BTrees/intkeymacros.h	2010-07-15 15:28:05 UTC (rev 114786)
+++ ZODB/trunk/src/BTrees/intkeymacros.h	2010-07-15 16:53:11 UTC (rev 114787)
@@ -25,7 +25,7 @@
   if (PyInt_Check(ARG)) {                                         \
       long vcopy = PyInt_AS_LONG(ARG);                            \
       if ((int)vcopy != vcopy) {                                  \
-        PyErr_SetObject(PyExc_OverflowError, ARG);                \
+        PyErr_SetString(PyExc_TypeError, "integer out of range"); \
         (STATUS)=0; (TARGET)=0;                                   \
       }                                                           \
       else TARGET = vcopy;                                        \

Modified: ZODB/trunk/src/BTrees/intvaluemacros.h
===================================================================
--- ZODB/trunk/src/BTrees/intvaluemacros.h	2010-07-15 15:28:05 UTC (rev 114786)
+++ ZODB/trunk/src/BTrees/intvaluemacros.h	2010-07-15 16:53:11 UTC (rev 114787)
@@ -24,7 +24,7 @@
   if (PyInt_Check(ARG)) {                                         \
       long vcopy = PyInt_AS_LONG(ARG);                            \
       if ((int)vcopy != vcopy) {                                  \
-        PyErr_SetObject(PyExc_OverflowError, ARG);                \
+        PyErr_SetString(PyExc_TypeError, "integer out of range"); \
         (STATUS)=0; (TARGET)=0;                                   \
       }                                                           \
       else TARGET = vcopy;                                        \

Modified: ZODB/trunk/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/trunk/src/BTrees/tests/testBTrees.py	2010-07-15 15:28:05 UTC (rev 114786)
+++ ZODB/trunk/src/BTrees/tests/testBTrees.py	2010-07-15 16:53:11 UTC (rev 114787)
@@ -1814,8 +1814,8 @@
             i = int(i)
             try:
                 b[i] = 0
-            except (OverflowError, TypeError), v:
-                self.assertRaises(v.__class__, b.__setitem__, 0, i)
+            except TypeError:
+                self.assertRaises(TypeError, b.__setitem__, 0, i)
             else:
                 good.add(i)
                 b[0] = i
@@ -1953,13 +1953,8 @@
         # the characteristics change to match the 64 bit version, please
         # feel free to change.
         big = BTrees.family32.maxint + 1
-        if isinstance(big, long):
-            self.assertRaises(TypeError, s.insert, big)
-            self.assertRaises(TypeError, s.insert, BTrees.family32.minint - 1)
-        else: # 64 bit Python
-            self.assertRaises(OverflowError, s.insert, big)
-            self.assertRaises(OverflowError, s.insert,
-                              BTrees.family32.minint - 1)
+        self.assertRaises(TypeError, s.insert, big)
+        self.assertRaises(TypeError, s.insert, BTrees.family32.minint - 1)
         self.check_pickling(BTrees.family32)
 
     def test64(self):

Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-07-15 15:28:05 UTC (rev 114786)
+++ ZODB/trunk/src/CHANGES.txt	2010-07-15 16:53:11 UTC (rev 114787)
@@ -2,6 +2,16 @@
  Change History
 ================
 
+3.10.0b4 (2010-07-15)
+=====================
+
+Bugs fixed
+----------
+
+- When an integer too large to fit in a 32-bit integer was provided as
+  a 32-bit-integer BTree key or value on 64-bit machines, an
+  OverflowError was raised. Now a TypeError is raised.
+
 3.10.0b3 (2010-07-15)
 =====================
 



More information about the Zodb-checkins mailing list