gh-152817: Prevent deletion of sqlite3 cursor.row_factory attr, missed from: gh-149738#152818
gh-152817: Prevent deletion of sqlite3 cursor.row_factory attr, missed from: gh-149738#152818stestagg wants to merge 6 commits into
cursor.row_factory attr, missed from: gh-149738#152818Conversation
prevent segfault and bring behaviour in line with docs
|
@sepehr-rs - You were the author of the original, are you able to take a look? Thanks in advance! |
sepehr-rs
left a comment
There was a problem hiding this comment.
Hi @stestagg, thank you for reaching out to me on this!
I think your change is good, but I believe you should also add a versionchanged:: next note under the Cursor.row_factory attribute docs, mirroring what was added for Connection.row_factory/text_factory. Besides that, +1 from me.
As I understand it, gh-149738 already altered the doc for the cpython/Doc/library/sqlite3.rst Lines 1718 to 1719 in f3bf8ab It's likely I've misunderstood/missed something here! |
Oh, you're right. I must have forgotten about that. This is a real gap, thanks for checking this! :) |
|
There's a related issue that I uncovered above, if you create a To me, there's a few options:
I'm not sure of the best approach tbh. |
re-initialize in tp_init (because of tp_clear calls) and also guard each use of row_factory and text_factory with an explicit NULL check. Keep the previous delattr guards, because who would be calling __delattr__ on these anyway. I'm imagining someone will suggest removing some of these changes, but something something seek forgiveness something.
|
I propose to split this into 2 PRs: one with the deletion, one with the assignement. Let's keep this PR focused on one thing :) |
…n, keeping the underlying delattr guards
fair point, reverted, I'll raise the other part separately |
gh-149738 prevents deletion of
row_factoryandtext_factoryattributes on a sqlite3 connection, this PR applies that fix tocursorobjects too, to avoid a similar segfault:I've piggy-backed off the existing docs change and blurb as that seems to cover this already
row_factoryattr of sqlite3cursor#152817