summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-02-21 11:58:40 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-02-21 12:04:46 (GMT)
commit4ab701b2d30f1975bbea837234f6dfe52785c3d5 (patch)
tree24bfc442848675af9290debb7d06e737e2fb0022 /Lib
parent36b7361fe76733b3a4944ef92b49bcea4584b740 (diff)
downloadcpython-4ab701b2d30f1975bbea837234f6dfe52785c3d5.zip
cpython-4ab701b2d30f1975bbea837234f6dfe52785c3d5.tar.gz
cpython-4ab701b2d30f1975bbea837234f6dfe52785c3d5.tar.bz2
sqlite3: Fix 64-bit integer handling in user functions on 32-bit architectures
Closes #8033.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/sqlite3/test/userfunctions.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index 80b6f0c..2db3a61 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -37,6 +37,8 @@ def func_returnnull():
return None
def func_returnblob():
return buffer("blob")
+def func_returnlonglong():
+ return 1<<31
def func_raiseexception():
5 // 0
@@ -50,6 +52,8 @@ def func_isnone(v):
return type(v) is type(None)
def func_isblob(v):
return type(v) is buffer
+def func_islonglong(v):
+ return isinstance(v, (int, long)) and v >= 1<<31
class AggrNoStep:
def __init__(self):
@@ -126,6 +130,7 @@ class FunctionTests(unittest.TestCase):
self.con.create_function("returnfloat", 0, func_returnfloat)
self.con.create_function("returnnull", 0, func_returnnull)
self.con.create_function("returnblob", 0, func_returnblob)
+ self.con.create_function("returnlonglong", 0, func_returnlonglong)
self.con.create_function("raiseexception", 0, func_raiseexception)
self.con.create_function("isstring", 1, func_isstring)
@@ -133,6 +138,7 @@ class FunctionTests(unittest.TestCase):
self.con.create_function("isfloat", 1, func_isfloat)
self.con.create_function("isnone", 1, func_isnone)
self.con.create_function("isblob", 1, func_isblob)
+ self.con.create_function("islonglong", 1, func_islonglong)
def tearDown(self):
self.con.close()
@@ -199,6 +205,12 @@ class FunctionTests(unittest.TestCase):
self.assertEqual(type(val), buffer)
self.assertEqual(val, buffer("blob"))
+ def CheckFuncReturnLongLong(self):
+ cur = self.con.cursor()
+ cur.execute("select returnlonglong()")
+ val = cur.fetchone()[0]
+ self.assertEqual(val, 1<<31)
+
def CheckFuncException(self):
cur = self.con.cursor()
try:
@@ -238,6 +250,12 @@ class FunctionTests(unittest.TestCase):
val = cur.fetchone()[0]
self.assertEqual(val, 1)
+ def CheckParamLongLong(self):
+ cur = self.con.cursor()
+ cur.execute("select islonglong(?)", (1<<42,))
+ val = cur.fetchone()[0]
+ self.assertEqual(val, 1)
+
class AggregateTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")