diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-08-05 06:45:29 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-08-05 06:45:29 -0500 |
| commit | 1c07453ef72025cec9f92daa448a0957900ce204 (patch) | |
| tree | 9bf6c3724afcee3dbcc7b1d87486b365fea0a517 /src/flake8 | |
| parent | 9a4abfbcb47283fa02d22811b001a3b52f2df97a (diff) | |
| parent | f434e9adf5ca8013a63511023d71bf210b0925b9 (diff) | |
| download | flake8-1c07453ef72025cec9f92daa448a0957900ce204.tar.gz | |
Merge branch 'bug/203'
Diffstat (limited to 'src/flake8')
| -rw-r--r-- | src/flake8/exceptions.py | 16 | ||||
| -rw-r--r-- | src/flake8/processor.py | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/flake8/exceptions.py b/src/flake8/exceptions.py index 71738b2..da650f9 100644 --- a/src/flake8/exceptions.py +++ b/src/flake8/exceptions.py @@ -36,17 +36,17 @@ class InvalidSyntax(Flake8Exception): def __init__(self, *args, **kwargs): """Initialize our InvalidSyntax exception.""" - self.original_exception = kwargs.pop('exception') + exception = kwargs.pop('exception', None) + self.original_exception = exception + self.error_message = str(exception) 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) + super(InvalidSyntax, self).__init__( + self.error_message, + *args, + **kwargs + ) class PluginRequestedUnknownParameters(Flake8Exception): diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 1d0e3a4..a3c9a6b 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -247,7 +247,7 @@ class FileProcessor(object): # course, I'm going to be unsurprised to be proven wrong at a later # date. except tokenize.TokenError as exc: - raise exceptions.InvalidSyntax(exc.message, exception=exc) + raise exceptions.InvalidSyntax(exception=exc) def line_for(self, line_number): """Retrieve the physical line at the specified line number.""" |
