Bug report
Bug description:
This is one of the errors printed by make test on CYGWIN:
FAIL: test_textmode (test.test_tempfile.TestMkstempInner.test_textmode)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/carlo/packages/python/cpython/Lib/test/test_tempfile.py", line 522, in test_textmode
self.assertEqual(os.read(f.fd, 20), b"blat")
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: b'blat\x1aextra\n' != b'blat'
For explaining this issue, some information must be listed about the CTRL-Z (0x1A):
On CYGWIN:
- Opening with
open() in binary mode, it handles it as a clean flow of data without translations.
- Opening with
open() in text mode, it translates all 0xA to 0xD 0xA and the read() function ignores the CTRL-Z character as EOF.
- Opening with
fopen() in text mode, it also accepts the CTRL-Z as the EOF condition and this stops receiving data from fread().
On native WIN32:
- both
open() and fopen() work in the same way if they open the file in text mode and CTRL-Z is treated as End-Of-File at both high and low levels, so read() and fread() give you the same results.
So, that's why this test is failing here.
In short, this kind of test cannot be executed on CYGWIN because read() never blocks on CTRL-Z by design.
I would like to suggest to avoid it, if it happens.
The patch itself is simple, I think that it is just need to write this before test_textmode:
@unittest.skipUnless(sys.platform != "cygwin" and has_textmode, "text mode not available")
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
Bug report
Bug description:
This is one of the errors printed by
make teston CYGWIN:For explaining this issue, some information must be listed about the CTRL-Z (0x1A):
On CYGWIN:
open()in binary mode, it handles it as a clean flow of data without translations.open()in text mode, it translates all 0xA to 0xD 0xA and theread()function ignores the CTRL-Z character as EOF.fopen()in text mode, it also accepts the CTRL-Z as the EOF condition and this stops receiving data fromfread().On native WIN32:
open()andfopen()work in the same way if they open the file in text mode and CTRL-Z is treated as End-Of-File at both high and low levels, soread()andfread()give you the same results.So, that's why this test is failing here.
In short, this kind of test cannot be executed on CYGWIN because
read()never blocks on CTRL-Z by design.I would like to suggest to avoid it, if it happens.
The patch itself is simple, I think that it is just need to write this before test_textmode:
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs