-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
os module: reject bytes-like strings for paths, only accept the exact bytes type #98393
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In Python 3.2, I removed support for bytearray in PyUnicode_FSConverter(): issue #52731, commit dcb2403.
It seems like support for bytes-like object was added again in Python 3.4 with commit a2ad5c3 (issue #60176):
Or maybe this change is unrelated, and Python 3.2 and 3.3 already accepted bytes-like types indirectly. |
I created PR #98394 to implement this change. |
Ah no, it was reintroduced in Python 3.3 with "the big path_converter changes": #70987 (comment) |
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.
In Python 3.6, the support for "bytes-like" paths was deprecated (commit d73c318): see issue #70987 for the rationale.
I propose to remove the support for bytes-like paths in Python 3.12. The feature was deprecated in 6 Python releases (PEP 387 is respected). In practice, the two most common "bytes-like" types are: bytearray and memoryview.
The text was updated successfully, but these errors were encountered: