Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Oct 18, 2022

The os module no longer accepts bytes-like paths, like bytearray and memoryview types: only the exact bytes type is accepted for bytes strings.

@vstinner
Copy link
Member Author

cc @serhiy-storchaka @methane

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.
@vstinner vstinner merged commit db03c80 into python:main Oct 18, 2022
@vstinner vstinner deleted the remove_os_buffer branch October 18, 2022 15:52
@vstinner
Copy link
Member Author

Merged, thanks for the review @methane!

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a 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.

for name in filenames:
try:
if isinstance(name, (str, bytes)):
if not isinstance(name, (str, bytes)):
Copy link
Member

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 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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list() is redundant here.

@vstinner
Copy link
Member Author

LGTM besides few tests nitpicks.

Since this PR is already merged, I created #98487 to take your review in account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants