[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-07 Thread Manuel Jacob
Manuel Jacob added the comment: It’s possible to trigger the problem on Unix with much smaller sizes, e.g. by interrupting the write() with a signal handler (even if the signal handler doesn’t do anything). The following script starts a subprocess doing a 16MiB write and sends a signal,

[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-06 Thread Manuel Jacob
Manuel Jacob added the comment: `io.TextIOWrapper.write()` returns the length of the passed string instead of the actually written number of characters. % python -u -c "import sys; print(sys.stdout.write('x'*4294967296), file=sys.stderr)" | wc -c 4294967296 2147479552 So the possibility

[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-06 Thread Manuel Jacob
Manuel Jacob added the comment: 2147479552 is the 0x7000 bytes limit documented for write() on Linux (source: https://man7.org/linux/man-pages/man2/write.2.html). The limit could be even smaller in other circumstances or other systems. I’m adding Victor Stinner to the nosy list, as he

[issue41221] Output of print() might get truncated in unbuffered mode

2020-07-06 Thread Manuel Jacob
New submission from Manuel Jacob : Without unbuffered mode, it works as expected: % python -c "import sys; sys.stdout.write('x'*4294967296)" | wc -c 4294967296 % python -c "import sys; print('x'*4294967296)" | wc -c 4294967297 With unbuffered mode, writes get truncated to 2147479552