Repository navigation
sdk/python: validate buffering and errors before opening files - #7898
Merged
jiefenghuang merged 3 commits intoNov 24, 2026
Merged
jiefenghuang merged 3 commits into
jiefenghuang merged 3 commits into
Conversation
adenzhou1350
requested review from
CaitinChen and
jiefenghuang
as code owners
November 20, 2026 10:59
CaitinChen
approved these changes
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Invalid options can alter a file before
Client.open()reports an error:"wb", buffering=Noneand"w", errors=1both truncate existing data before raisingTypeError. Creating modes can also leave an unwanted file behind. Python's standardopen()rejects these types before touching the file.Change
Validate integer
bufferingand string-or-Noneerrorsbefore native I/O. Integer-protocol objects remain supported. Previously accepted float buffer sizes and falsy non-string error handlers now raiseTypeError. Update regressions and both SDK guides.Validation
22 selected project SDK tests pass locally on Linux (open, readinto, seek and truncate). The errors-option regressions fail in 20 subcases on the earlier buffering-only PR head, then pass with this addition. Normal integer buffering and text error handlers are covered.
The native comparison used Python 3.12, task-private SQLite fixtures and a reused libjfs build. Full backend CI and a fresh native rebuild were not run locally. Applicable pinned whitespace hooks pass.
Official CI passes on
ec7ae7d22: all 29 checks are green; the MySQL, Redis and TiKV Python SDK jobs each pass 83 tests.AI-assisted source audit, patch and tests; validation executed as described above.