bpo-42064: Migrate to sqlite3_create_collation_v2#27156
Conversation
This implies that SQLite now takes care of destroying the callback context (the PyObject callable it has been passed), so we can strip the collation dict from the connection object.
|
|
Sorry, something went wrong.
|
FYI, the test suite already exercise clearing a collation callback and re-registering a collation callback. |
Sorry, something went wrong.
|
BTW, I'd like to change the |
Sorry, something went wrong.
encukou
left a comment
There was a problem hiding this comment.
Looks good so far!
I see that the beginning of the function does some busywork converting name to uppercase and checking for allowed characters. Is that limitation there only to make that sure comparison of keys in the collations dict match sqlite3_strnicmp? If so, PyUnicode_AsUTF8(name) could be used instead.
As for the finally→error rename, I'd say finally is a better name when it's also executed in the non-error case...
Sorry, something went wrong.
Yes, I noticed that part as well. I haven't investigated why this was added in the first place. I'll try with
True. |
Sorry, something went wrong.
|
FYI, the collation code (including the uppercase conversion / check), was added to UPDATE: UPDATE AGAIN: |
Sorry, something went wrong.
|
Thank you! |
Sorry, something went wrong.
Sync with main after pythonGH-27156.
As a nice side effect, we can now remove the collation dict from the
connection object, since SQLite now takes care of destroying the
callback context.
This change is needed in order to make it more convenient to add a
module state to the
sqlite3module.https://bugs.python.org/issue42064