You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sqlite3: exception from a collation callback is replaced by SystemError #161837
When a collation callback raises, sqlite3 returns 0 to SQLite and leaves the exception pending. SQLite keeps evaluating the row, and a later failure in the same step (here abs() of the smallest 64-bit integer, an integer overflow) makes sqlite3 build its own OperationalError with the collation's exception still set. The interpreter reports this as a SystemError, and the original exception is lost.
Expected: the collation's exception should propagate, or at least chain as the cause.
Reproducer
importsqlite3defcoll(a, b):
ifa=="boom":
raiseKeyError("collation raised")
return (a>b) - (a<b)
con=sqlite3.connect(":memory:")
con.create_collation("c", coll)
con.execute("create table t(x, y)")
con.executemany("insert into t values (?, ?)",
[(1, "a"), (-9223372036854775808, "boom")])
cur=con.execute("select case when y = 'q' collate c then abs(x) else 0 end from t")
cur.fetchone()
KeyError: 'collation raised'The above exception was the direct cause of the following exception:SystemError: <class 'sqlite3.OperationalError'> returned a result with an exception set
Activity