-
Notifications
You must be signed in to change notification settings - Fork 1.4k
sqlite3: fix Blob.__setitem__ value range validation #7981
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
Changes from all commits
95abd48
6f3eae8
1df29c5
c074556
57accdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,3 +53,20 @@ def finalize(self): | |
| cx.create_aggregate("aggtxt", 1, AggrText) | ||
| cur.execute("select aggtxt(key) from foo") | ||
| assert cur.fetchone()[0] == "341011" | ||
|
|
||
| # Blob extended-slice assignment with negative step | ||
| # Guard: CPython 3.11 has a SystemError bug with negative-step Blob slicing; | ||
| # this test only runs on RustPython where the fix is being validated. | ||
| # TODO: remove this once https://github.com/python/cpython/pull/150450 is released and RustPython CI uses it. | ||
| import sys | ||
|
|
||
| if sys.implementation.name == "rustpython": | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we usually don't add rustpython-only code. is this CPython bug? Then is this reported to CPython?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the negative-step slice crash is a CPython bug — I've filed it upstream as python/cpython#150449 and submitted a fix PR (python/cpython#150450). However, this PR also contains a few pre-existing RustPython-only bugs unrelated to that CPython issue:
Should I split this into two PRs — one for the CPython-mirrored negative-step fix (which could be reverted or marked |
||
| cx.execute("CREATE TABLE blobtest(b BLOB)") | ||
| data = b"this blob data string is exactly fifty bytes long!" | ||
| cx.execute("INSERT INTO blobtest(b) VALUES (?)", (data,)) | ||
| blob = cx.blobopen("blobtest", "b", 1) | ||
| blob[9:0:-2] = b"12345" # writes to indices 9, 7, 5, 3, 1 | ||
| actual = cx.execute("select b from blobtest").fetchone()[0] | ||
| expected = b"t5i4 3l2b1" + data[10:] | ||
| assert actual == expected, f"got {actual!r}, expected {expected!r}" | ||
| blob.close() | ||
Uh oh!
There was an error while loading. Please reload this page.