You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
As was brought to my attention that
os.{read,write}
only handles interpolation to/from bytes in python 3.While using
os.read
andos.write
on python 2 works "out-of-the-box" on withstr
since the type is bytes-based, it doesn't on python 3. Example: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 theio
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.
The text was updated successfully, but these errors were encountered: