-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Closed
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
import io
import tokenize
src = '''\
a = f"""
Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""
'''
tokens = list(tokenize.generate_tokens(io.StringIO(src).readline))
for token in tokens:
print(token)
assert tokens[4].start == (2, 68), tokens[4].start
Python 3.12.3 (correct)
❯ python --version
Python 3.12.3
❯ python c.py
TokenInfo(type=1 (NAME), string='a', start=(1, 0), end=(1, 1), line='a = f"""\n')
TokenInfo(type=55 (OP), string='=', start=(1, 2), end=(1, 3), line='a = f"""\n')
TokenInfo(type=61 (FSTRING_START), string='f"""', start=(1, 4), end=(1, 8), line='a = f"""\n')
TokenInfo(type=62 (FSTRING_MIDDLE), string='\n Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli', start=(1, 8), end=(2, 68), line='a = f"""\n Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""\n')
TokenInfo(type=63 (FSTRING_END), string='"""', start=(2, 68), end=(2, 71), line=' Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""\n')
TokenInfo(type=4 (NEWLINE), string='\n', start=(2, 71), end=(2, 72), line=' Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""\n')
TokenInfo(type=0 (ENDMARKER), string='', start=(3, 0), end=(3, 0), line='')
Python 3.12.4 (broken)
❯ python --version
Python 3.12.4
❯ python c.py
TokenInfo(type=1 (NAME), string='a', start=(1, 0), end=(1, 1), line='a = f"""\n')
TokenInfo(type=55 (OP), string='=', start=(1, 2), end=(1, 3), line='a = f"""\n')
TokenInfo(type=61 (FSTRING_START), string='f"""', start=(1, 4), end=(1, 8), line='a = f"""\n')
TokenInfo(type=62 (FSTRING_MIDDLE), string='\n Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli', start=(1, 8), end=(2, 68), line='a = f"""\n Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""\n')
TokenInfo(type=63 (FSTRING_END), string='"""', start=(2, 72), end=(2, 75), line=' Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""\n')
TokenInfo(type=4 (NEWLINE), string='\n', start=(2, 75), end=(2, 76), line=' Autorzy, którzy tą jednostkę mają wpisani jako AKTUALNA -- czyli"""\n')
TokenInfo(type=0 (ENDMARKER), string='', start=(3, 0), end=(3, 0), line='')
Traceback (most recent call last):
File "/private/tmp/flake8/c.py", line 13, in <module>
assert tokens[4].start == (2, 68), tokens[4].start
^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: (2, 72)
More info
I found previous similar issue here: #112943
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Linked PRs
- gh-120343: Do not reset byte_col_offset_diff after multiline tokens #120352
- [3.13] gh-120343: Do not reset byte_col_offset_diff after multiline tokens (GH-120352) #120355
- [3.12] gh-120343: Do not reset byte_col_offset_diff after multiline tokens (GH-120352) #120356
- gh-120343: Fix column offsets of multiline tokens in tokenize #120391
- [3.13] gh-120343: Fix column offsets of multiline tokens in tokenize (GH-120391) #120427
- [3.12] gh-120343: Fix column offsets of multiline tokens in tokenize (GH-120391) #120428
lovejoy
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error