This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: os.write.__doc__ is misleading
Type: behavior Stage: resolved
Components: Versions: Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ethan.furman, python-dev, shai, terry.reedy
Priority: normal Keywords:

Created on 2013-05-18 16:44 by shai, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg189535 - (view) Author: Shai Berger (shai) Date: 2013-05-18 16:44
At least on posix systems, os.write says it takes a string, but in fact it barfs on strings -- it needs bytes.

$ python
Python 3.3.1 (default, May  6 2013, 16:18:33) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print(os.write.__doc__)
write(fd, string) -> byteswritten

Write a string to a file descriptor.
>>> os.write(1, "hello")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
>>> os.write(1, b"hello")
msg189935 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-24 21:36
New changeset 7935844c6737 by Benjamin Peterson in branch '3.3':
indicate that read/write work with bytes (closes #18009)
Date User Action Args
2022-04-11 14:57:45adminsetgithub: 62209
2013-05-24 21:36:19python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg189935

resolution: fixed
stage: resolved
2013-05-24 20:18:39terry.reedysetnosy: + terry.reedy
2013-05-18 17:09:08ethan.furmansetnosy: + ethan.furman
2013-05-18 16:44:29shaicreate