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.

Author dsm001
Recipients dsm001
Date 2009-04-25.22:45:22
SpamBayes Score 1.1660117e-12
Marked as misclassified No
Message-id <1240699525.42.0.125859784134.issue5844@psf.upfronthosting.co.za>
In-reply-to
Content
Inspired by http://bugs.python.org/issue1653416 , I tried writing to a
file opened for reading in 3.1 trunk, and found:

Python 3.1a2+ (py3k:71900M, Apr 25 2009, 16:12:31) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> fp = open('/etc/passwd')
>>> fp.write('test')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: null argument to internal routine
>>> print('test',file=fp)        
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: null argument to internal routine

but binary mode gives:

>>> fp = open('/etc/passwd','rb')
>>> fp.write(b'test')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: write
>>> print(b'test',file=fp)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: write
History
Date User Action Args
2009-04-25 22:45:25dsm001setrecipients: + dsm001
2009-04-25 22:45:25dsm001setmessageid: <1240699525.42.0.125859784134.issue5844@psf.upfronthosting.co.za>
2009-04-25 22:45:23dsm001linkissue5844 messages
2009-04-25 22:45:22dsm001create