This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: io.TextIOWrapper.tell() report 65bit number when mix readline() + tell()
Type: behavior Stage: resolved
Components: IO, Library (Lib) Versions: Python 3.3, Python 3.4, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: EcmaXp_, martin.panter, vstinner
Priority: normal Keywords:

Created on 2016-01-05 15:05 by EcmaXp_, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg257531 - (view) Author: EcmaXp_ (EcmaXp_) Date: 2016-01-05 15:05
I did test on 
- Python 3.5.1 on Windows 64 Bit and 32 Bit (Machine A)
- Python 3.4.4 on Windows 32 Bit (Machine A)
- Python 3.4.3+ on Ubuntu 15.10 64 Bit (Virtual Machine on Machine A)
- Python 3.4.2 on Machine B and C
- Python 3.3.5 on Windows 32 Bit (Machine A)

I did test but not produce bug. (report 8 correctly)
- Python 3.2.5 on Windows 32 Bit (Machine A)
- Python 3.1.4 on Windows 32 Bit (Machine A)
- Python 2.7.10 on Windows 64 Bit (Machine A) 

Machine A: i7-5775C with Windows 10 (build 10586.36) 64 Bit
Machine B: http://www.tutorialspoint.com/execute_python3_online.php
Machine C: https://repl.it/languages/python3

Code are here

import io
with io.TextIOWrapper(io.BytesIO(b'.\r\n...\r\n\r\n\r\n')) as fp:
    fp.readline() # '.\n'
    fp.readline() # '......\n'
    print(fp.tell()) # 18446744073709551628 = 0x10000000000000009

Not only those string produce bug, also adding more dot make produce bug sometimes.
msg257532 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-01-05 15:07
Yeah, it's expected that tell() can return big numbers. It returns a black box "cookie".

https://docs.python.org/dev/library/io.html#id3

https://docs.python.org/dev/library/io.html#io.TextIOWrapper
msg257533 - (view) Author: EcmaXp_ (EcmaXp_) Date: 2016-01-05 15:10
second fp.readline() # '......\n' is actaully '...\n'
mistake
msg257545 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-05 20:20
The documentation for tell() <https://docs.python.org/3/library/io.html#io.TextIOBase.tell> says that it returns an opaque number. Depending on the codec used, it might have to record the state of the text decoder, CRLF decoder, byte position, etc, all in that number. So I don’t think the return value being large is a bug.

Perhaps the change in behaviour from Python 2 is due to Issue 11114. Also, Issue 25849 was recently opened about text file seeking.
msg263704 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-04-19 02:29
EcmaXp: Do you think there is anything we can do for this? I think the cases discussed here are working as intended.
History
Date User Action Args
2022-04-11 14:58:25adminsetgithub: 70204
2017-03-07 19:09:36serhiy.storchakasetstatus: pending -> closed
stage: resolved
2016-11-27 00:55:21eric.smithlinkissue28804 superseder
2016-04-19 02:29:32martin.pantersetstatus: open -> pending
resolution: not a bug
messages: + msg263704
2016-01-05 20:20:23martin.pantersetnosy: + martin.panter
messages: + msg257545
2016-01-05 15:10:24EcmaXp_setmessages: + msg257533
2016-01-05 15:07:12vstinnersetnosy: + vstinner
messages: + msg257532
2016-01-05 15:05:36EcmaXp_create