classification
Title: TextIOWrapper: bad error reporting when write() is forbidden
Type: behavior Stage:
Components: IO Versions: Python 3.1
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: dsm001, pitrou
Priority: critical Keywords:

Created on 2009-04-27 21:36 by pitrou, last changed 2009-04-27 22:27 by benjamin.peterson. This issue is now closed.

Messages (2)
msg86700 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-04-27 21:36
Opening an existing file in read-only text mode and trying to write to it:

>>> f = open("LICENSE")
>>> f.write("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: null argument to internal routine

Binary files get it right though:

>>> f = open("LICENSE", "rb")
>>> f.write("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: write
msg86704 - (view) Author: DSM (dsm001) Date: 2009-04-27 22:26
See also http://bugs.python.org/issue5844 , which contains a patch to test.
History
Date User Action Args
2009-04-27 22:27:25benjamin.petersonsetstatus: open -> closed
resolution: duplicate
2009-04-27 22:26:36dsm001setnosy: + dsm001
messages: + msg86704
2009-04-27 21:36:54pitroucreate