René's URL Explorer Experiment


Title: sqlite3: fix Blob.__setitem__ value range validation by ever0de · Pull Request #7981 · RustPython/RustPython · GitHub

Open Graph Title: sqlite3: fix Blob.__setitem__ value range validation by ever0de · Pull Request #7981 · RustPython/RustPython

X Title: sqlite3: fix Blob.__setitem__ value range validation by ever0de · Pull Request #7981 · RustPython/RustPython

Description: Previously, assigning an out-of-range integer (negative or > 255) or an integer too large for i64 (e.g. 2**65) to a Blob index raised OverflowError instead of ValueError. Mirror CPython's ass_subscript_index logic: Convert the value via to_i64(), treating any overflow as -1 Validate the result is in [0, 255], raising ValueError("byte must be in range(0, 256)") otherwise Separate deletion error messages: "item deletion" for index, "slice deletion" for slice Ref: https://github.com/python/cpython/blob/main/Modules/_sqlite/blob.c Problem When assigning an out-of-range integer to a Blob index, RustPython raised OverflowError instead of ValueError: blob[0] = -1 # OverflowError: Python int too large to convert to Rust u8 blob[0] = 256 # OverflowError blob[0] = 2**65 # OverflowError CPython raises ValueError: byte must be in range(0, 256) for all three cases. Root Cause The previous implementation used try_to_primitive::(vm)? to convert the assigned value, which calls Rust's type conversion and raises a generic OverflowError for any value that doesn't fit in u8 — including negative numbers. Fix Mirrors CPython's ass_subscript_index logic: // CPython blob.c long val = PyLong_AsLong(value); if (val == -1 && PyErr_Occurred()) { PyErr_Clear(); val = -1; // treat overflow as out-of-range } if (val < 0 || val > 255) { PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); return -1; } In Rust: Replace try_to_primitive::() with as_bigint().to_i64().unwrap_or(-1) Values that overflow i64 (e.g. 2**65) are treated as -1, which then fails the range check Raises ValueError("byte must be in range(0, 256)") for any value outside [0, 255] Additionally, aligned the deletion error messages with CPython: del blob[0] → "Blob doesn't support item deletion" del blob[5:10] → "Blob doesn't support slice deletion" Changes _sqlite3.rs: Fix Blob::ass_subscript index branch test_dbapi.py: Remove @unittest.expectedFailure from test_blob_set_item_error Summary by CodeRabbit Bug Fixes Fixed single-byte BLOB assignment to properly validate byte values and handle integer overflow. Improved BLOB slice assignment so unaffected bytes are preserved for complex slices, including negative-step writes. Tests Added a regression test for extended-slice BLOB assignments to prevent future regressions.

Open Graph Description: Previously, assigning an out-of-range integer (negative or > 255) or an integer too large for i64 (e.g. 2**65) to a Blob index raised OverflowError instead of ValueError. Mirror CPython's as...

X Description: Previously, assigning an out-of-range integer (negative or &gt; 255) or an integer too large for i64 (e.g. 2**65) to a Blob index raised OverflowError instead of ValueError. Mirror CPython&...

Opengraph URL: https://github.com/RustPython/RustPython/pull/7981

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:33d7d8d0-6884-8b72-8988-71013f81dc1e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA1B2:10B1AF:1482DC9:1C124EC:6A508A98
html-safe-noncebaf306106b65120b60284f1dd5cb5e0a61cf53cac7ef2b43c2e75bfe6a08451a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUIyOjEwQjFBRjoxNDgyREM5OjFDMTI0RUM6NkE1MDhBOTgiLCJ2aXNpdG9yX2lkIjoiMTg1Mjk0MzE1MDYzMDM0MTI3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacad5aa87c0460568e9b8fc3579b83699716407adaab08756578f2fc7a22b01886
hovercard-subject-tagpull_request:3745218356
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/7981/files
twitter:imagehttps://avatars.githubusercontent.com/u/27040963?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/27040963?s=400&v=4
og:image:altPreviously, assigning an out-of-range integer (negative or > 255) or an integer too large for i64 (e.g. 2**65) to a Blob index raised OverflowError instead of ValueError. Mirror CPython's as...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/7981/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7981%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F7981%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/7981/files
Reloadhttps://github.com/RustPython/RustPython/pull/7981/files
Reloadhttps://github.com/RustPython/RustPython/pull/7981/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 287 https://github.com/RustPython/RustPython/issues
Pull requests 92 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
ever0de:fix/sqlite-blob-set-item-error-validationhttps://github.com/ever0de/RustPython/tree/fix/sqlite-blob-set-item-error-validation
Conversation 7 https://github.com/RustPython/RustPython/pull/7981
Commits 5 https://github.com/RustPython/RustPython/pull/7981/commits
Checks 26 https://github.com/RustPython/RustPython/pull/7981/checks
Files changed https://github.com/RustPython/RustPython/pull/7981/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
sqlite3: fix Blob.__setitem__ value range validation https://github.com/RustPython/RustPython/pull/7981/files#top
Show all changes 5 commits https://github.com/RustPython/RustPython/pull/7981/files
95abd48 sqlite3: fix Blob.__setitem__ value range validation ever0de May 26, 2026 https://github.com/RustPython/RustPython/pull/7981/commits/95abd482bf66c052f1e08f4d9b30ff887ffb0e55
6f3eae8 sqlite3: fix Blob.__setitem__ negative-step slice write ever0de May 26, 2026 https://github.com/RustPython/RustPython/pull/7981/commits/6f3eae877f2e18ee521e632bdbd7aca309fc4a3b
1df29c5 fix: guard blob negative-step snippet from CPython 3.11 bug ever0de May 26, 2026 https://github.com/RustPython/RustPython/pull/7981/commits/1df29c5f065026922ee96a374a6d31d019666cd9
c074556 style: add blank line after import sys in stdlib_sqlite snippet (ruff) ever0de May 26, 2026 https://github.com/RustPython/RustPython/pull/7981/commits/c074556a20a594341e2df7f704e9e92fc6a5fb8d
57accdb Update extra_tests/snippets/stdlib_sqlite.py youknowone May 27, 2026 https://github.com/RustPython/RustPython/pull/7981/commits/57accdbca3328186c8bc873390b5a7de8d4f777d
Clear filters https://github.com/RustPython/RustPython/pull/7981/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
test_dbapi.py https://github.com/RustPython/RustPython/pull/7981/files#diff-8e2e6a9df72f1a10e817fcf22c760aebeabd549d12d1f6d4a921085462288e4b
_sqlite3.rs https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
stdlib_sqlite.py https://github.com/RustPython/RustPython/pull/7981/files#diff-af714534f7f9037baf4a054f88622295acbbf331b8266316cbc5efd1476304e9
Lib/test/test_sqlite3/test_dbapi.pyhttps://github.com/RustPython/RustPython/pull/7981/files#diff-8e2e6a9df72f1a10e817fcf22c760aebeabd549d12d1f6d4a921085462288e4b
View file https://github.com/ever0de/RustPython/blob/57accdbca3328186c8bc873390b5a7de8d4f777d/Lib/test/test_sqlite3/test_dbapi.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7981/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7981/files#diff-8e2e6a9df72f1a10e817fcf22c760aebeabd549d12d1f6d4a921085462288e4b
https://github.com/RustPython/RustPython/pull/7981/files#diff-8e2e6a9df72f1a10e817fcf22c760aebeabd549d12d1f6d4a921085462288e4b
crates/stdlib/src/_sqlite3.rshttps://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
View file https://github.com/ever0de/RustPython/blob/57accdbca3328186c8bc873390b5a7de8d4f777d/crates/stdlib/src/_sqlite3.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7981/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
https://github.com/RustPython/RustPython/pull/7981/files#diff-5a5ea8fc8d5bfc6b5da126f9574990e39802662762f23a2a6a9143beca021e15
extra_tests/snippets/stdlib_sqlite.pyhttps://github.com/RustPython/RustPython/pull/7981/files#diff-af714534f7f9037baf4a054f88622295acbbf331b8266316cbc5efd1476304e9
View file https://github.com/ever0de/RustPython/blob/57accdbca3328186c8bc873390b5a7de8d4f777d/extra_tests/snippets/stdlib_sqlite.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/7981/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/7981/files#diff-af714534f7f9037baf4a054f88622295acbbf331b8266316cbc5efd1476304e9
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
youknowonehttps://github.com/youknowone
May 26, 2026https://github.com/RustPython/RustPython/pull/7981/files#r3304291318
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
ever0dehttps://github.com/ever0de
May 26, 2026https://github.com/RustPython/RustPython/pull/7981/files#r3304382335
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
python/cpython#150449https://github.com/python/cpython/issues/150449
python/cpython#150450https://github.com/python/cpython/pull/150450
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/7981/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.