PyCQA / PyCQA/pycodestyle

Crash on triple quoted string with line continuation

Open
#713 10 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.