Flake8 throws AttributeError exception
Please provide the following version information
- Version of Python which has Flake8 installed : python3.5.2(e.g.,
python -V
) - Installed using pip (e.g.,
pip
,apt
,yum
, etc.)- pip version = 8.1.2(e.g.,
pip --version
)
- pip version = 8.1.2(e.g.,
- Version of setuptools installed : 25.1.0
- Version of Flake8 installed (pyflakes: 1.2.3, pycodestyle: 2.0.0, mccabe: 0.5.2) CPython 3.5.2 on Linux Please describe the problem or feature
- This problem arises only if there is a syntax error in the file i am checking :
I run flake8 myfile.py
It throws an AttributeError saying TokenError object has no attribute message, i am pretty sure this has something to do with the fact that python3 has no message attribute for it's Exception class which TokenError inherits from.
Here is the deatailed traceback:
Traceback (most recent call last):
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/site-packages/flake8/processor.py", line 238, in generate_tokens
for token in tokenize.generate_tokens(self.next_line):
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/tokenize.py", line 597, in _tokenize
raise TokenError("EOF in multi-line statement", (lnum, 0))
tokenize.TokenError: ('EOF in multi-line statement', (8, 0))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
self.run()
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/site-packages/flake8/checker.py", line 46, in _run_checks_from_queue
checker.run_checks(results_queue, statistics_queue)
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/site-packages/flake8/checker.py", line 579, in run_checks
self.process_tokens()
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/site-packages/flake8/checker.py", line 554, in process_tokens
for token in file_processor.generate_tokens():
File "/home/vikash/lpackages/anaconda3/envs/MLenv/lib/python3.5/site-packages/flake8/processor.py", line 250, in generate_tokens
raise exceptions.InvalidSyntax(exc.message, exception=exc)
AttributeError: 'TokenError' object has no attribute 'message'
I am thinking the exc.message should be str(exc) for python3.
EDIT:
I have verified, changing exc.message to str(exc) along with fixing another piece of code in exceptions.py which had a similar issue, fixed the problem.
I don't know if what i did was a temporary work-around or a correct fix, please look into it.