Skip to content

TextIOWrapper: stream.tell() returns big 64 bits random number #93077

Closed as not planned
@mguinhos

Description

@mguinhos

I was writing a lexer, and found this weird bug in python

Python version: Python 3.10.4
Os: Windows 11 21H2

...
Token.LeftParenthesis
char:  '"' tell:  102
None
char:  ')' tell:  18446744073709551746
-----> tell: 18446744073709551746
-----> tell: 18446744073709551745
Traceback (most recent call last):
  File "C:\Users\Usuário\Documents\Projetos\Bug\bug.py", line 11, in <module>
    for token in tokenize(open(fname)):
  File "C:\Users\Usuário\Documents\Projetos\Bug\tokenizer.py", line 85, in tokenize     
    yield scan_token(stream)
  File "C:\Users\Usuário\Documents\Projetos\Bug\tokenizer.py", line 58, in scan_token   
    raise SyntaxError(f'invalid token {stream.read(1)!r}')
SyntaxError: invalid token '\n'

i couldnt reproduce this bug with a example with less than 100 lines, but it is pretty organized

Obs:.

  • MAX = 2**64 = 18446744073709551616
  • If we subtract: MAX - 18446744073709551746 = -130

Here is the bug files:
Bug.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-IOtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions