[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-06-01 Thread Cheryl Sabella
Change by Cheryl Sabella : -- nosy: +benjamin.peterson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-06-01 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: Further testing revealed the problem and fix also apply to text mode. I submitted a pull request to fix this issue with tests for both binary and text mode. -- ___ Python tracker

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-31 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : -- keywords: +patch pull_requests: +13604 stage: -> patch review pull_request: https://github.com/python/cpython/pull/13717 ___ Python tracker

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-31 Thread PEW's Corner
PEW's Corner added the comment: Your proposal sounds good to me, Jeffrey. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-30 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: I ran another C test where I called lseek(fd, 0, SEEK_CUR) in-between each of the stream I/O functions to see how it reports the buffered and kernel file positions: opening file with wb writing 3 bytes to file lseek: 0 ftell(f): expecting 3, got 3 lseek:

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-30 Thread PEW's Corner
PEW's Corner added the comment: Great analysis, Jeffrey. Does the kernel position actually move to the end of the file on the f.write() in step 10, or on the flush in step 14? If it's the latter, then f.write() should probably call lseek() to set both the kernel position and internal

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-30 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: I did some tracing through bpo-36411.py using pdb and lldb. The problem is that the file position variables stored in the buffered file object get out of sync with the kernel in the write operation after the seek(0) call. It thinks it is writing to the

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-28 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: I saw the bug in the C output after I hit submit. Here is the correct output: opening file with wb writing 3 bytes to file ftell(f): expecting 3, got 3 closing file opening file with a+b ftell(f): expecting 3, got 3 writing 3 bytes to file ftell(f):

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-28 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : Removed file: https://bugs.python.org/file48369/bpo-36411.c ___ Python tracker ___ ___ Python-bugs-list

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-28 Thread Jeffrey Kintscher
Change by Jeffrey Kintscher : Added file: https://bugs.python.org/file48369/bpo-36411.c ___ Python tracker ___ ___ Python-bugs-list mailing

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-28 Thread Jeffrey Kintscher
Jeffrey Kintscher added the comment: I adapted the test code on StackOverflow to show the expected and actual values. I get this output using Python 2.7.16: opening myfile with wb writing 3 bytes to file ('f.tell(): expecting 3, got', 3) closing myfile opening myfile with a+b ('f.tell():

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-24 Thread PEW's Corner
PEW's Corner added the comment: But buffers are used - and update tell() correctly - in all other cases than binary append+read mode (and even this case works in Python 2). Also, the implementation clearly tries to keep tell() updated irrespective of the buffer, so isn't it just a matter of

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-23 Thread Windson Yang
Windson Yang added the comment: I think we should mention it at the document, like in the tell() function. -- ___ Python tracker ___

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-05-23 Thread Windson Yang
Windson Yang added the comment: I'm not sure it's a bug. When you write binary data to file (use BufferedIOBase by default). It actually writes the data to a buffer. That is why tell() gets out of sync. You can follow the instrument belolw. For instance, call flush() after writing to get

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-03-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: 'Python 3.9' does not exist yet. This choice is for patches that should only be applied to 3.9 when available (like future deprecations or removals). -- nosy: +terry.reedy versions: -Python 3.9 ___ Python

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-03-24 Thread Windson Yang
Windson Yang added the comment: This looks interesting. Let me try to fix it. -- nosy: +Windson Yang versions: +Python 3.8, Python 3.9 -Python 3.6 ___ Python tracker ___

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-03-24 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +martin.panter, serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing

[issue36411] Python 3 f.tell() gets out of sync with file pointer in binary append+read mode

2019-03-23 Thread PEW's Corner
New submission from PEW's Corner : When a file is opened in binary append+read mode, i.e. open('file', 'a+b'), and a write (i.e. append) operation is performed while the file pointer is not at the end of the file (e.g. after a seek(0)), tell() will subsequently return the wrong value in