[pypy-svn] pypy default: sqlite: It seems better to exit the query earlier when a callback cannot be run.

amauryfa commits-noreply at bitbucket.org
Thu Feb 10 11:41:25 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41763:48d194e3ac07
Date: 2011-02-09 19:40 +0100
http://bitbucket.org/pypy/pypy/changeset/48d194e3ac07/

Log:	sqlite: It seems better to exit the query earlier when a callback
	cannot be run.

diff --git a/lib-python/modified-2.7.0/sqlite3/test/userfunctions.py b/lib-python/modified-2.7.0/sqlite3/test/userfunctions.py
--- a/lib-python/modified-2.7.0/sqlite3/test/userfunctions.py
+++ b/lib-python/modified-2.7.0/sqlite3/test/userfunctions.py
@@ -275,12 +275,14 @@
             pass
 
     def CheckAggrNoStep(self):
+        # XXX it's better to raise OperationalError in order to stop
+        # the query earlier.
         cur = self.con.cursor()
         try:
             cur.execute("select nostep(t) from test")
-            self.fail("should have raised an AttributeError")
-        except AttributeError, e:
-            self.assertEqual(e.args[0], "AggrNoStep instance has no attribute 'step'")
+            self.fail("should have raised an OperationalError")
+        except sqlite.OperationalError, e:
+            self.assertEqual(e.args[0], "user-defined aggregate's 'step' method raised error")
 
     def CheckAggrNoFinalize(self):
         cur = self.con.cursor()

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -578,9 +578,8 @@
                     aggregate = self.aggregate_instances[aggregate_ptr[0]]
 
                 params = _convert_params(context, argc, c_params)
-                step = aggregate.step
                 try:
-                    step(*params)
+                    aggregate.step(*params)
                 except Exception, e:
                     msg = ("user-defined aggregate's 'step' "
                            "method raised error")


More information about the Pypy-commit mailing list