classification
Title: sqlite3 trace callback prints duplicate line
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: anish.shah, berker.peksag, ghaering, palaviv, xiang.zhang
Priority: normal Keywords:

Created on 2016-01-23 19:34 by palaviv, last changed 2017-04-09 09:12 by berker.peksag. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 434 closed anish.shah, 2017-03-03 19:39
PR 461 merged palaviv, 2017-03-04 09:31
Messages (6)
msg258874 - (view) Author: Aviv Palivoda (palaviv) * Date: 2016-01-23 19:34
I am running the following script:

------------------------------------------
>>> import sqlite3
>>> import os
>>> import time
>>> con1 = sqlite3.connect("/tmp/test.db")
>>> con2 = sqlite3.connect("/tmp/test.db")
>>> con1.set_trace_callback(print)
>>> cur = con1.cursor()
>>> cur.execute("create table test(a)")
create table test(a)
<sqlite3.Cursor object at 0x7fb488ddf260>
>>> con2.execute("create table test2(a)")
<sqlite3.Cursor object at 0x7fb488ddf2d0>
>>> cur.execute("insert into test(a) values(1)")
BEGIN 
insert into test(a) values(1)
insert into test(a) values(1)
<sqlite3.Cursor object at 0x7fb488ddf260>
>>> for a in con1.execute("select * from test"):
...     print("result:", a)
... 
select * from test
result: (1,)
-------------------------------------------

As you can see i get duplicate traceback print of the "insert into test(a) values(1)" line. The duplicate print has no effect on the actual db.

I have tested this both on python 3.4.3 and 3.6.0a0 on ubuntu14.04
msg264549 - (view) Author: Aviv Palivoda (palaviv) * Date: 2016-04-30 10:37
This issue will be resolved when we change the sqlite3_prepare to sqlite3_prepare_v2. So there should be a dependency on issue 9303.
msg288876 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-03-03 11:06
It would be nice to add a test case to https://github.com/python/cpython/blob/86a670543ff97d52fd9b8ca0477f8b6d27ee946d/Lib/sqlite3/test/hooks.py#L204 before closing this.
msg288913 - (view) Author: Anish Shah (anish.shah) * Date: 2017-03-03 19:06
I can work on this.
msg291359 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-04-09 09:12
New changeset 0e6cb2ea624570ed08c354f1ed1f595dab4192d6 by Berker Peksag (Aviv Palivoda) in branch 'master':
bpo-26187: Test that set_trace_callback() is not called multiple times (GH-461)
https://github.com/python/cpython/commit/0e6cb2ea624570ed08c354f1ed1f595dab4192d6
msg291361 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-04-09 09:12
Thanks, Anish and Aviv!
History
Date User Action Args
2017-04-09 09:12:48berker.peksagsetstatus: open -> closed
resolution: fixed
messages: + msg291361

stage: patch review -> resolved
2017-04-09 09:12:01berker.peksagsetmessages: + msg291359
2017-03-04 09:31:25palavivsetpull_requests: + pull_request384
2017-03-04 00:34:11berker.peksagsetstage: test needed -> patch review
2017-03-03 19:39:04anish.shahsetpull_requests: + pull_request360
2017-03-03 19:06:42anish.shahsetnosy: + anish.shah
messages: + msg288913
2017-03-03 11:06:15berker.peksagsetversions: + Python 3.7, - Python 3.4, Python 3.6
nosy: + berker.peksag

messages: + msg288876

stage: test needed
2016-04-30 10:37:45palavivsetmessages: + msg264549
2016-01-25 09:40:16xiang.zhangsetnosy: + xiang.zhang
2016-01-23 19:34:32palavivcreate