Repository navigation
Conversation
…ring fetch A collation callback cannot report an error to SQLite, so the Python exception stays set. A later error in the same step can make sqlite3_step() fail. Then pysqlite_cursor_iternext() calls set_error_from_db() with the exception still set. This causes a SystemError. In debug builds, an assertion fails. _pysqlite_query_execute() already prints or clears the pending exception before it raises the DB-API exception. Move that code into the new helper clear_callback_error() and use it in both functions.
The test compares the printed traceback with plain text. When colors are enabled, the traceback contains escape codes and the comparison fails. Use force_not_colorized to make the output plain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A collation callback cannot report an error to SQLite, so the Python exception stays set. A later error in the same step can make
sqlite3_step()fail. On theexecute()path, the module prints or clears the pending exception and then raisesOperationalError. On the fetch path (fetchone(),fetchmany(),fetchall()and iteration),pysqlite_cursor_iternext()callsset_error_from_db()with the exception still set. This causes aSystemErrorin release builds. In debug builds, an assertion fails intype_call().This change moves the existing code from
_pysqlite_query_execute()into a new helper,clear_callback_error(), and calls it from both functions. The behavior ofexecute()does not change. Now the fetch path has the same behavior asexecute():OperationalError.sqlite3.enable_callback_tracebacks(True), the module also prints the collation traceback.The new test does
fetchone()and iteration, with tracebacks enabled and disabled. Without the fix, the test causes an assertion failure on a debug build. With the fix,test_sqlite3passes, and-R 3:3shows no reference leaks.