mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 23:54:17 +00:00
Ensure column_number is always an integer
When a SyntaxError is raised, column_number may be None. Unfortunately, it's not obvious where that None comes from so we must handle it in handle_error. Closes #214
This commit is contained in:
parent
1631ab8ac7
commit
585628875d
1 changed files with 4 additions and 1 deletions
|
|
@ -253,7 +253,10 @@ class StyleGuide(object):
|
||||||
int
|
int
|
||||||
"""
|
"""
|
||||||
# NOTE(sigmavirus24): Apparently we're provided with 0-indexed column
|
# NOTE(sigmavirus24): Apparently we're provided with 0-indexed column
|
||||||
# numbers so we have to offset that here.
|
# numbers so we have to offset that here. Also, if a SyntaxError is
|
||||||
|
# caught, column_number may be None.
|
||||||
|
if not column_number:
|
||||||
|
column_number = 0
|
||||||
error = Error(code, filename, line_number, column_number + 1, text,
|
error = Error(code, filename, line_number, column_number + 1, text,
|
||||||
physical_line)
|
physical_line)
|
||||||
error_is_selected = (self.should_report_error(error.code) is
|
error_is_selected = (self.should_report_error(error.code) is
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue