Issue 5844: internal error on write while reading (original) (raw)
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 "", line 1, in SystemError: null argument to internal routine print('test',file=fp)
Traceback (most recent call last): File "", line 1, in 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 "", line 1, in io.UnsupportedOperation: write print(b'test',file=fp) Traceback (most recent call last): File "", line 1, in io.UnsupportedOperation: write