[Zodb-checkins] SVN: ZODB/branches/3.8/ Bug fixed:
Jim Fulton
jim at zope.com
Mon Sep 20 17:26:47 EDT 2010
Log message for revision 116690:
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/branches/3.8/NEWS.txt
U ZODB/branches/3.8/src/BTrees/intkeymacros.h
U ZODB/branches/3.8/src/BTrees/intvaluemacros.h
U ZODB/branches/3.8/src/BTrees/tests/testBTrees.py
-=-
Modified: ZODB/branches/3.8/NEWS.txt
===================================================================
--- ZODB/branches/3.8/NEWS.txt 2010-09-20 20:50:32 UTC (rev 116689)
+++ ZODB/branches/3.8/NEWS.txt 2010-09-20 21:26:47 UTC (rev 116690)
@@ -15,7 +15,7 @@
- Passing keys or values outside the range of 32-bit ints on 64-bit
platforms led to undetected overflow errors. Now these cases cause
- Overflow errors to be raised.
+ TypeErrors to be raised.
https://bugs.launchpad.net/zodb/+bug/143237
Modified: ZODB/branches/3.8/src/BTrees/intkeymacros.h
===================================================================
--- ZODB/branches/3.8/src/BTrees/intkeymacros.h 2010-09-20 20:50:32 UTC (rev 116689)
+++ ZODB/branches/3.8/src/BTrees/intkeymacros.h 2010-09-20 21:26:47 UTC (rev 116690)
@@ -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/branches/3.8/src/BTrees/intvaluemacros.h
===================================================================
--- ZODB/branches/3.8/src/BTrees/intvaluemacros.h 2010-09-20 20:50:32 UTC (rev 116689)
+++ ZODB/branches/3.8/src/BTrees/intvaluemacros.h 2010-09-20 21:26:47 UTC (rev 116690)
@@ -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/branches/3.8/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/branches/3.8/src/BTrees/tests/testBTrees.py 2010-09-20 20:50:32 UTC (rev 116689)
+++ ZODB/branches/3.8/src/BTrees/tests/testBTrees.py 2010-09-20 21:26:47 UTC (rev 116690)
@@ -1632,8 +1632,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
@@ -1771,13 +1771,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):
More information about the Zodb-checkins
mailing list