From 324a4a882411b6755995fbca596c47fa7d4101f6 Mon Sep 17 00:00:00 2001 From: Anthony Tuininga Date: Wed, 22 Oct 2008 18:31:31 +0000 Subject: [PATCH] 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. --- test/CursorVar.py | 2 +- test/uCursorVar.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/CursorVar.py b/test/CursorVar.py index 8624f3c..5d8d686 100644 --- a/test/CursorVar.py +++ b/test/CursorVar.py @@ -37,7 +37,7 @@ class TestCursorVar(BaseTestCase): cursor(select IntCol + 1 from dual) CursorValue from TestNumbers order by IntCol""") - size = len(struct.pack("i", 1)) + size = struct.calcsize('P') self.failUnlessEqual(self.cursor.description, [ ('INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0), ('CURSORVALUE', cx_Oracle.CURSOR, -1, size, 0, 0, 1) ]) diff --git a/test/uCursorVar.py b/test/uCursorVar.py index 669af65..3b41fb2 100644 --- a/test/uCursorVar.py +++ b/test/uCursorVar.py @@ -1,5 +1,6 @@ """Module for testing cursor variables.""" +import struct import sys class TestCursorVar(BaseTestCase): @@ -36,10 +37,7 @@ class TestCursorVar(BaseTestCase): cursor(select IntCol + 1 from dual) CursorValue from TestNumbers order by IntCol""") - if len(str(sys.maxint)) == 10: - size = 4 - else: - size = 8 + size = struct.calcsize('P') self.failUnlessEqual(self.cursor.description, [ (u'INTCOL', cx_Oracle.NUMBER, 10, 22, 9, 0, 0), (u'CURSORVALUE', cx_Oracle.CURSOR, -1, size, 0, 0, 1) ])