Author: Brian Kearns <[email protected]>
Branch:
Changeset: r62127:cdcf1ad3fcbe
Date: 2013-03-06 03:57 -0500
http://bitbucket.org/pypy/pypy/changeset/cdcf1ad3fcbe/
Log: test and fix for sqlite check_cursor behavior
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -791,8 +791,15 @@
self.__connection._check_thread()
self.__connection._check_closed()
+ def __check_cursor_wrap(func):
+ @wraps(func)
+ def wrapper(self, *args, **kwargs):
+ self.__check_cursor()
+ return func(self, *args, **kwargs)
+ return wrapper
+
+ @__check_cursor_wrap
def execute(self, sql, params=None):
- self.__check_cursor()
self.__locked = True
try:
self.__description = None
@@ -836,8 +843,8 @@
return self
+ @__check_cursor_wrap
def executemany(self, sql, many_params):
- self.__check_cursor()
self.__locked = True
try:
self.__description = None
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
@@ -58,6 +58,9 @@
cur.close()
con.close()
pytest.raises(_sqlite3.ProgrammingError, "cur.close()")
+ # raises ProgrammingError because should check closed before check args
+ pytest.raises(_sqlite3.ProgrammingError, "cur.execute(1,2,3,4,5)")
+ pytest.raises(_sqlite3.ProgrammingError, "cur.executemany(1,2,3,4,5)")
@pytest.mark.skipif("not hasattr(sys, 'pypy_translation_info')")
def test_cursor_del():
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit