Message11916
This would be better as a distinct test, and maybe in test_file_jy. We always aim *not* to have a special Jython variant of a CPython test (under the same file name). We do here already, but it would be nice not to make it diverge further.
I think that earlier you demonstrated the bug only when the start position of the readline was not the start of the file. Using essentially your code and CPython 2.7.14 I get:
testSeekTell (__main__.AutoFileTests2) ... FAIL
======================================================================
FAIL: testSeekTell (__main__.AutoFileTests2)
----------------------------------------------------------------------
Traceback (most recent call last):
File "dist\Lib\test\test_fileio.py", line 63, in testSeekTell
self.assertEqual(self.f.tell(), 31)
AssertionError: 10L != 31
The first line of the file is terminated by the \x0a byte, that was inserted by self.f.write(bytes(range(20))). If we keep the file, instead of tidying up, we can see (CPython):
>>> f = open('$test_1_tmp', 'r')
>>> f.readline()
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n'
>>> f.readline()
'\x0b\x0c\r\x0eJython is great\n'
>>> f.close()
I was surprised the \r is not also a line end, but that's a thing you have to ask for explicitly:
>>> f = open('$test_1_tmp', 'rU') # U = universal newlines mode
>>> f.readline()
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n'
>>> f.readline()
'\x0b\x0c\n'
>>> f.readline()
'\x0eJython is great\n'
>>> f.close()
We perhaps have a bone to pick with CPython. Since this byte is at index 10 in the file, and the return from readline includes that byte, I think Jython is correct to return 11 and CPython is off by one! |
|
Date |
User |
Action |
Args |
2018-04-19 06:56:54 | jeff.allen | set | messageid: <1524121014.86.0.682650639539.issue2363@psf.upfronthosting.co.za> |
2018-04-19 06:56:54 | jeff.allen | set | recipients:
+ jeff.allen, fwierzbicki, zyasoft, santa4nt, amit, psykiatris |
2018-04-19 06:56:54 | jeff.allen | link | issue2363 messages |
2018-04-19 06:56:54 | jeff.allen | create | |
|