summaryrefslogtreecommitdiff
path: root/Lib/sqlite3/test/hooks.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-07 16:59:34 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-07 16:59:34 +0200
commit35c52b687ffa044a0a5a1fe2ef477ce653d926b7 (patch)
tree684d887a9f234d05af5126ebdd7c2137f0c0b51a /Lib/sqlite3/test/hooks.py
parentd5327d95d2c345f384cc9d03be0d9c4e8773b277 (diff)
downloadcpython-git-35c52b687ffa044a0a5a1fe2ef477ce653d926b7.tar.gz
Issue #17073: Fix some integer overflows in sqlite3 module.
Diffstat (limited to 'Lib/sqlite3/test/hooks.py')
-rw-r--r--Lib/sqlite3/test/hooks.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py
index b798e749ad..2bfae10bcb 100644
--- a/Lib/sqlite3/test/hooks.py
+++ b/Lib/sqlite3/test/hooks.py
@@ -76,6 +76,25 @@ class CollationTests(unittest.TestCase):
except sqlite.OperationalError, e:
self.assertEqual(e.args[0].lower(), "no such collation sequence: mycoll")
+ def CheckCollationReturnsLargeInteger(self):
+ def mycoll(x, y):
+ # reverse order
+ return -((x > y) - (x < y)) * 2**32
+ con = sqlite.connect(":memory:")
+ con.create_collation("mycoll", mycoll)
+ sql = """
+ select x from (
+ select 'a' as x
+ union
+ select 'b' as x
+ union
+ select 'c' as x
+ ) order by x collate mycoll
+ """
+ result = con.execute(sql).fetchall()
+ self.assertEqual(result, [('c',), ('b',), ('a',)],
+ msg="the expected order was not returned")
+
def CheckCollationRegisterTwice(self):
"""
Register two different collation functions under the same name.