This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author torsten
Recipients ghaering, pitrou, torsten
Date 2011-03-27.17:38:22
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1301247504.36.0.600973759097.issue11688@psf.upfronthosting.co.za>
In-reply-to
Content
> A couple of comments:
> - this is a new feature, so can only go in in 3.x: no need to post a 2.7 patch (unless this helps Gerhard for his standalone project)

The motivation for the 2.7er patch is mostly that we are still using Python 2.x at work and I made this patch for 2.7 first. Actually I will need to backport it to 2.6 but I guess there are no differences. And maybe I should have submitted this against pysqlite directly which is (AFAICT) also still targetting 2.x.

> - you need to document the new API in Doc/library/sqlite3.rst

Sure. I was just filing the report to have the code on file and this was only fallout from another patch. I will create an updated patch including documentation about the feature.

> About the patch: looks mostly good!

Thanks.

> +        self.assertTrue([x for x in traced_statements if x.find("create table foo") != -1])
>
> This looks a bit complicated, why not something like
> `any("create table foo" in x for x in traced_statements)`?

Fine with me. I did not know that "bar" in "foobarbaz" works (I was expecting it to act as if the right hand string is a list of characters). Obviously I was wrong. Further I thought "any" was new in 2.6 and therefore not suitable for use in pysqlite which was also wrong.

> (`y in x` is simper and more readable than `x.find(y) != -1`)

I agree, I just did not know it works for substrings.

> +        sqlite3_trace(self->db, _trace_callback, trace_callback);
> +        if (PyDict_SetItem(self->function_pinboard, trace_callback, Py_None) == -1)
> +            return NULL;
>
> Shouldn't sqlite3_trace() be called only after PyDict_SetItem() succeeds?

Good catch. If SetItem fails, trace_callback may become invalid and the _trace_callback will crash. I did not think about that as I only derived that function from similar code in the module. I will have to fix this as well.
History
Date User Action Args
2011-03-27 17:38:24torstensetrecipients: + torsten, ghaering, pitrou
2011-03-27 17:38:24torstensetmessageid: <1301247504.36.0.600973759097.issue11688@psf.upfronthosting.co.za>
2011-03-27 17:38:22torstenlinkissue11688 messages
2011-03-27 17:38:22torstencreate