[pypy-commit] pypy stdlib-2.7.4: test and fix for some _sqlite3 behavior changes
bdkearns
noreply at buildbot.pypy.org
Thu Apr 11 00:37:03 CEST 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.4
Changeset: r63215:734cac0606a1
Date: 2013-04-10 18:36 -0400
http://bitbucket.org/pypy/pypy/changeset/734cac0606a1/
Log: test and fix for some _sqlite3 behavior changes
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -787,7 +787,9 @@
try:
ret = callback(action, arg1, arg2, dbname, source)
assert isinstance(ret, int)
- assert ret in (_lib.SQLITE_OK, _lib.SQLITE_DENY, _lib.SQLITE_IGNORE)
+ # try to detect cases in which cffi would swallow
+ # OverflowError when casting the return value
+ assert int(_ffi.cast('int', ret)) == ret
return ret
except Exception:
return _lib.SQLITE_DENY
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -222,3 +222,11 @@
cur.execute("create table test(a)")
cur.executemany("insert into test values (?)", [[1], [2], [3]])
assert cur.lastrowid is None
+
+def test_authorizer_bad_value(con):
+ def authorizer_cb(action, arg1, arg2, dbname, source):
+ return 42
+ con.set_authorizer(authorizer_cb)
+ with pytest.raises(_sqlite3.OperationalError) as e:
+ con.execute('select 42')
+ assert str(e.value) == 'authorizer malfunction'
More information about the pypy-commit
mailing list