diff options
author | Ian Lee <IanLee1521@gmail.com> | 2015-07-15 01:53:05 -0600 |
---|---|---|
committer | Ian Lee <IanLee1521@gmail.com> | 2015-07-15 01:53:05 -0600 |
commit | 151758ce8f29fd65e10dc0720446c5a3bb164602 (patch) | |
tree | 49bf66c2d1c35ebbb50cb413e52d09f013bc0d99 | |
parent | 99efd5ad90047b5512d04c57fe41ad05cbc25b41 (diff) | |
parent | d48eef071003952ed0f98445dc3dc6bc29618f9c (diff) | |
download | pep8-151758ce8f29fd65e10dc0720446c5a3bb164602.tar.gz |
Merge pull request #420 from myint/master
Support Python 3.5
-rw-r--r-- | .travis.yml | 1 | ||||
-rwxr-xr-x | pep8.py | 13 | ||||
-rw-r--r-- | testsuite/test_api.py | 3 |
3 files changed, 14 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml index 4d619e9..b8fabef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ python: - 3.2 - 3.3 - 3.4 + - nightly - pypy - pypy3 install: @@ -1314,6 +1314,13 @@ if COMMENT_WITH_NL: _checks = {'physical_line': {}, 'logical_line': {}, 'tree': {}} +def _get_parameters(function): + if sys.version_info >= (3, 3): + return list(inspect.signature(function).parameters) + else: + return inspect.getargspec(function)[0] + + def register_check(check, codes=None): """Register a new check object.""" def _add_check(check, kind, codes, args): @@ -1322,13 +1329,13 @@ def register_check(check, codes=None): else: _checks[kind][check] = (codes or [''], args) if inspect.isfunction(check): - args = inspect.getargspec(check)[0] + args = _get_parameters(check) if args and args[0] in ('physical_line', 'logical_line'): if codes is None: codes = ERRORCODE_REGEX.findall(check.__doc__ or '') _add_check(check, args[0], codes, args) elif inspect.isclass(check): - if inspect.getargspec(check.__init__)[0][:2] == ['self', 'tree']: + if _get_parameters(check.__init__)[:2] == ['self', 'tree']: _add_check(check, 'tree', codes, None) @@ -1504,7 +1511,7 @@ class Checker(object): """Build the file's AST and run all AST checks.""" try: tree = compile(''.join(self.lines), '', 'exec', PyCF_ONLY_AST) - except (SyntaxError, TypeError): + except (ValueError, SyntaxError, TypeError): return self.report_invalid_syntax() for name, cls, __ in self._ast_checks: checker = cls(tree, self.filename) diff --git a/testsuite/test_api.py b/testsuite/test_api.py index 341fb34..1cb0d4b 100644 --- a/testsuite/test_api.py +++ b/testsuite/test_api.py @@ -339,6 +339,9 @@ class APITestCase(unittest.TestCase): if 'SyntaxError' in stdout: # PyPy 2.2 returns a SyntaxError expected = "stdin:1:2: E901 SyntaxError" + elif 'ValueError' in stdout: + # Python 3.5. + expected = "stdin:1:1: E901 ValueError" else: expected = "stdin:1:1: E901 TypeError" self.assertTrue(stdout.startswith(expected), |