mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 02:46:52 +00:00
Do not treat AttributeError as if it were an IOError
...and avoid .strerror altogether since py3 does not have it. See #203.
This commit is contained in:
parent
45ae0b9eeb
commit
cddf982a0a
1 changed files with 2 additions and 7 deletions
|
|
@ -36,16 +36,11 @@ class InvalidSyntax(Flake8Exception):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize our InvalidSyntax exception."""
|
||||
self.original_exception = kwargs.pop('exception')
|
||||
self.original_exception = exc = kwargs.pop('exception')
|
||||
self.error_message = str(exc) if exc is not None else ''
|
||||
self.error_code = 'E902'
|
||||
self.line_number = 1
|
||||
self.column_number = 0
|
||||
try:
|
||||
self.error_message = self.original_exception.message
|
||||
except AttributeError:
|
||||
# On Python 3, the IOError is an OSError which has a
|
||||
# strerror attribute instead of a message attribute
|
||||
self.error_message = self.original_exception.strerror
|
||||
super(InvalidSyntax, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue