New submission from Andrew McNabb <amcn...@mcnabbs.org>: The following snippet behaves differently in the C IO implementation than in the Python IO implementation:
import sys sys.stdout.write('unicode ') sys.stdout.buffer.write(b'bytes ') To test this, I have created two scripts, testpyio.py (using _pyio) and testio.py (using _io). The output is as follows: % python3 testpyio.py unicode bytes % python3 testio.py bytes unicode % In my opinion, the behavior exhibited by _pyio is more correct. It appears that to get the C implementation to print the lines in the correct order, there must be a flush in between the statements. This extra flush would create a lot of overhead. I am attaching the two test scripts. The C implementation prints the output in the correct order if each write ends with a newline. ---------- components: IO files: testpyio.py messages: 99496 nosy: amcnabb severity: normal status: open title: TextIOWrapper Buffering Inconsistent Between _io and _pyio type: behavior versions: Python 3.1 Added file: http://bugs.python.org/file16248/testpyio.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7955> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com