gh-98393: os module reject bytes-like, only accept bytes#98394
Merged
vstinner merged 2 commits intopython:mainfrom Oct 18, 2022
vstinner:remove_os_buffer
Merged
gh-98393: os module reject bytes-like, only accept bytes#98394vstinner merged 2 commits intopython:mainfrom vstinner:remove_os_buffer
vstinner merged 2 commits intopython:mainfrom
vstinner:remove_os_buffer
Conversation
Member
Author
methane
approved these changes
Oct 18, 2022
The os module and the PyUnicode_FSDecoder() function no longer accept bytes-like paths, like bytearray and memoryview types: only the exact bytes type is accepted for bytes strings.
Member
Author
|
Merged, thanks for the review @methane! |
Member
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM besides few tests nitpicks.
| for name in filenames: | ||
| try: | ||
| if isinstance(name, (str, bytes)): | ||
| if not isinstance(name, (str, bytes)): |
Member
There was a problem hiding this comment.
I would move these cases into separate test. It is not anymore about the filename attribute of OSError.
| self.assertIs(type(entry.name), bytes) | ||
| self.assertIs(type(entry.path), bytes) | ||
| with self.assertRaises(TypeError): | ||
| list(os.scandir(path_bytes)) |
Member
There was a problem hiding this comment.
list() is redundant here.
Member
Author
Since this PR is already merged, I created #98487 to take your review in account. |
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.
The os module no longer accepts bytes-like paths, like bytearray and memoryview types: only the exact bytes type is accepted for bytes strings.