Crash on triple quoted string with line continuation
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
Given the file:
foo = \
"""bar
"""
pycodestyle 2.3.1 crashes:
$ pycodestyle demo.py
Traceback (most recent call last):
File "/users/is/whughes/pyenvs/research3/bin/pycodestyle", line 11, in <module>
sys.exit(_main())
File "/users/is/whughes/pyenvs/research3/lib/python2.7/site-packages/pycodestyle.py", line 2309, in _main
report = style_guide.check_files()
File "/users/is/whughes/pyenvs/research3/lib/python2.7/site-packages/pycodestyle.py", line 2010, in check_files
runner(path)
File "/users/is/whughes/pyenvs/research3/lib/python2.7/site-packages/pycodestyle.py", line 2022, in input_file
return fchecker.check_all(expected=expected, line_offset=line_offset)
File "/users/is/whughes/pyenvs/research3/lib/python2.7/site-packages/pycodestyle.py", line 1785, in check_all
self.check_logical()
File "/users/is/whughes/pyenvs/research3/lib/python2.7/site-packages/pycodestyle.py", line 1663, in check_logical
for offset, text in self.run_check(check, argument_names) or ():
File "/users/is/whughes/pyenvs/research3/lib/python2.7/site-packages/pycodestyle.py", line 633, in continued_indentation
rel_indent[end[0] - first_row] = rel_indent[row]
IndexError: list assignment index out of range
This looks like a regression on #388.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with the shown demo.py input, then inspect continued_indentation in pycodestyle.py, where the traceback reports the failing list assignment. The work is done when pycodestyle no longer crashes on this triple-quoted string with a line continuation and the regression is covered by the project's tests, if applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100