Skip to content
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

os.{read,write} isn't handled by futurize; affected by bytes/unicode str change in python 3 #566

Open
ngie-eign opened this issue Jun 17, 2020 · 0 comments

Comments

@ngie-eign
Copy link

ngie-eign commented Jun 17, 2020

As was brought to my attention that os.{read,write} only handles interpolation to/from bytes in python 3.

While using os.read and os.write on python 2 works "out-of-the-box" on with str since the type is bytes-based, it doesn't on python 3. Example:

>>> import os
>>> fd = os.open(os.devnull, os.O_WRONLY)
>>> os.write(fd, "foobar")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'

It would have been helpful if a built-in alias had been installed for str to match the new behavior, or something similar had been done using a backport from the io module.

Note: I am aware that the number of future releases with new code is decreasing over time: this is mainly being provided as documentation, since this caveat wasn't mentioned anywhere obvious I noted and there are some orgs who are still working on their python 2-3 conversions.

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

No branches or pull requests

1 participant