IndexError with Unicode double border character
hugovk opened this issue · comments
how did you install flake8?
$ pip install flake8
Requirement already satisfied: flake8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (7.1.0)
Requirement already satisfied: mccabe<0.8.0,>=0.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from flake8) (0.7.0)
Requirement already satisfied: pycodestyle<2.13.0,>=2.12.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from flake8) (2.12.0)
Requirement already satisfied: pyflakes<3.3.0,>=3.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from flake8) (3.2.0)
unmodified output of flake8 --bug-report
{
"platform": {
"python_implementation": "CPython",
"python_version": "3.12.4",
"system": "Darwin"
},
"plugins": [
{
"plugin": "mccabe",
"version": "0.7.0"
},
{
"plugin": "pycodestyle",
"version": "2.12.0"
},
{
"plugin": "pyflakes",
"version": "3.2.0"
}
],
"version": "7.1.0"
}
describe the problem
what I expected to happen
No IndexError
, flake8 to report any style issues found.
sample code
assert ("""
╝""".strip()
)
Minimal reproducer from this full test case: https://github.com/jazzband/prettytable/blob/f044b0e2c99680c975e5d4523771f819934f4611/tests/test_prettytable.py#L1205-L1222
Also a problem with other double border characters, works okay replacing it with some ASCII thing like "a".
No problem if removing the .strip()
, or running Black which removes the wrapping parentheses:
assert """
╝""".strip()
commands ran
$ ❯ flake8 t.py
Found existing alias for "flake8". You should use: "f8"
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/bin/flake8", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/main/cli.py", line 23, in main
app.run(argv)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/main/application.py", line 198, in run
self._run(argv)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/main/application.py", line 187, in _run
self.run_checks()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/main/application.py", line 103, in run_checks
self.file_checker_manager.run()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/checker.py", line 238, in run
self.run_serial()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/checker.py", line 221, in run_serial
).run_checks()
^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/checker.py", line 527, in run_checks
self.process_tokens()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/checker.py", line 512, in process_tokens
self.handle_newline(token_type)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/checker.py", line 542, in handle_newline
self.run_logical_checks()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/checker.py", line 439, in run_logical_checks
comments, logical_line, mapping = self.processor.build_logical_line()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/processor.py", line 231, in build_logical_line
comments, logical, mapping_list = self.build_logical_line_tokens()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/flake8/processor.py", line 212, in build_logical_line_tokens
previous_text = self.lines[row_index][column_index]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
IndexError: string index out of range
this is a bug in cpython 3.12.4 and will be fixed in 3.12.5
Thank you, confirmed fixed with the latest 3.12 branch.