Commit d5a9f2e9 authored by Jim Fulton's avatar Jim Fulton

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.
parent d1dc2637
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
if (PyInt_Check(ARG)) { \ if (PyInt_Check(ARG)) { \
long vcopy = PyInt_AS_LONG(ARG); \ long vcopy = PyInt_AS_LONG(ARG); \
if ((int)vcopy != vcopy) { \ if ((int)vcopy != vcopy) { \
PyErr_SetObject(PyExc_OverflowError, ARG); \ PyErr_SetString(PyExc_TypeError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \ (STATUS)=0; (TARGET)=0; \
} \ } \
else TARGET = vcopy; \ else TARGET = vcopy; \
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
if (PyInt_Check(ARG)) { \ if (PyInt_Check(ARG)) { \
long vcopy = PyInt_AS_LONG(ARG); \ long vcopy = PyInt_AS_LONG(ARG); \
if ((int)vcopy != vcopy) { \ if ((int)vcopy != vcopy) { \
PyErr_SetObject(PyExc_OverflowError, ARG); \ PyErr_SetString(PyExc_TypeError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \ (STATUS)=0; (TARGET)=0; \
} \ } \
else TARGET = vcopy; \ else TARGET = vcopy; \
......
...@@ -1814,8 +1814,8 @@ class IIBTreeTest(BTreeTests): ...@@ -1814,8 +1814,8 @@ class IIBTreeTest(BTreeTests):
i = int(i) i = int(i)
try: try:
b[i] = 0 b[i] = 0
except (OverflowError, TypeError), v: except TypeError:
self.assertRaises(v.__class__, b.__setitem__, 0, i) self.assertRaises(TypeError, b.__setitem__, 0, i)
else: else:
good.add(i) good.add(i)
b[0] = i b[0] = i
...@@ -1953,13 +1953,8 @@ class FamilyTest(TestCase): ...@@ -1953,13 +1953,8 @@ class FamilyTest(TestCase):
# the characteristics change to match the 64 bit version, please # the characteristics change to match the 64 bit version, please
# feel free to change. # feel free to change.
big = BTrees.family32.maxint + 1 big = BTrees.family32.maxint + 1
if isinstance(big, long): self.assertRaises(TypeError, s.insert, big)
self.assertRaises(TypeError, s.insert, big) self.assertRaises(TypeError, s.insert, BTrees.family32.minint - 1)
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.check_pickling(BTrees.family32) self.check_pickling(BTrees.family32)
def test64(self): def test64(self):
......
...@@ -38,7 +38,7 @@ Bugs Fixed ...@@ -38,7 +38,7 @@ Bugs Fixed
- Passing keys or values outside the range of 32-bit ints on 64-bit - Passing keys or values outside the range of 32-bit ints on 64-bit
platforms led to undetected overflow errors. Now these cases cause platforms led to undetected overflow errors. Now these cases cause
Overflow errors to be raised. Type errors to be raised.
https://bugs.launchpad.net/zodb/+bug/143237 https://bugs.launchpad.net/zodb/+bug/143237
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment