Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-98393: os module reject bytes-like, only accept bytes#98394
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The os module and the PyUnicode_FSDecoder() function no longer acceptbytes-like paths, like bytearray and memoryview types: only the exactbytes type is accepted for bytes strings.
Merged, thanks for the review@methane! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM besides few tests nitpicks.
@@ -3860,18 +3860,18 @@ def test_oserror_filename(self): | |||
for filenames, func, *func_args in funcs: | |||
for name in filenames: | |||
try: | |||
if isinstance(name, (str, bytes)): | |||
if not isinstance(name, (str, bytes)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would move these cases into separate test. It is not anymore about thefilename
attribute of OSError.
self.assertIs(type(entry.name), bytes) | ||
self.assertIs(type(entry.path), bytes) | ||
with self.assertRaises(TypeError): | ||
list(os.scandir(path_bytes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
list()
is redundant here.
Since this PR is already merged, I created#98487 to take your review in account. |
Uh oh!
There was an error while loading.Please reload this page.
The os module no longer accepts bytes-like paths, like bytearray and memoryview types: only the exact bytes type is accepted for bytes strings.