Use struct.calcsize('P') to determine the size of a pointer rather than

depend on the value of sys.maxint which differs on 64-bit platforms.
This commit is contained in:
Anthony Tuininga 2008-10-22 18:31:31 +00:00
parent 4692ae6a71
commit 324a4a8824
2 changed files with 3 additions and 5 deletions

View File

@ -37,7 +37,7 @@ class TestCursorVar(BaseTestCase):
cursor(select IntCol + 1 from dual) CursorValue cursor(select IntCol + 1 from dual) CursorValue
from TestNumbers from TestNumbers
order by IntCol""") order by IntCol""")
size = len(struct.pack("i", 1)) size = struct.calcsize('P')
self.failUnlessEqual(self.cursor.description, self.failUnlessEqual(self.cursor.description,
[ ('INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0), [ ('INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0),
('CURSORVALUE', cx_Oracle.CURSOR, -1, size, 0, 0, 1) ]) ('CURSORVALUE', cx_Oracle.CURSOR, -1, size, 0, 0, 1) ])

View File

@ -1,5 +1,6 @@
"""Module for testing cursor variables.""" """Module for testing cursor variables."""
import struct
import sys import sys
class TestCursorVar(BaseTestCase): class TestCursorVar(BaseTestCase):
@ -36,10 +37,7 @@ class TestCursorVar(BaseTestCase):
cursor(select IntCol + 1 from dual) CursorValue cursor(select IntCol + 1 from dual) CursorValue
from TestNumbers from TestNumbers
order by IntCol""") order by IntCol""")
if len(str(sys.maxint)) == 10: size = struct.calcsize('P')
size = 4
else:
size = 8
self.failUnlessEqual(self.cursor.description, self.failUnlessEqual(self.cursor.description,
[ (u'INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0), [ (u'INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0),
(u'CURSORVALUE', cx_Oracle.CURSOR, -1, size, 0, 0, 1) ]) (u'CURSORVALUE', cx_Oracle.CURSOR, -1, size, 0, 0, 1) ])