-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-129603: Don't segfault if sqlite3.Row description is None #129604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-129603: Don't segfault if sqlite3.Row description is None #129604
Conversation
ae502d7
to
6f029cd
Compare
Alternatively, we could disallow instantiation of |
Expanding on this: adding this check to the |
Any other opinions on this, @picnixz? |
Are there situations where one needs to create an instance of an sqlite row from a cursor with no description? (even creating rows manually by passing a cursor feels a bit weird to me, but there are maybe cases when it's needed, I don't know, probably for libs interfacing even more with sqlite3). If so, this may be better to keep the current PR (which can be backported probably) and then do a follow-up PR and:
If it doesn't make sense to instantiate a row with a cursor that has no description (and I think it doesn't make sense to do this but I may be mistaken), then we can just have this additional check at construction time. I doubt it will slow down since it's just an additional Now, if rows with None descriptions were instantiated manually, and even if they don't make sense or reflect bad code practice, they were already broken when keys were being used but we could still use them with numeric indices. So there might be some code that is not entirely broken out there. If you want to be super-conservative, let's go down the deprecation road (but it's annoying for both the users and us to maintain), so I think we can just forbid instantiating such rows in 3.14+. For 3.12 and 3.13, we can leave it as is just to avoid possible reports. |
As I wrote in the issue OP, I don't think any real world code instantiates |
Yeah, that's why I suggested the (annoying) deprecation road. The PR doesn't look super complicate and I don't think we have other places where we need to be careful with the type of the description (maybe you could add a comment in the object structure saying that it can be None and thus should be carefully checked?). |
Note: |
Hm, I'm not sure we even need that check. I'm strangely unable to trigger a crash for that path. |
Ah, it's using |
We should be fine with using the fast get-size API for both of the cases this PR touches. That should even out the potential slowdown of the None-check. |
Slight digression: we could speed up |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
GH-129923 is a backport of this pull request to the 3.13 branch. |
GH-129924 is a backport of this pull request to the 3.12 branch. |
…None (python#129604) (cherry picked from commit 7e6ee50)
pysqlite_Row->description == PyNone
#129603