Skip to content

Commit 151758c

Browse files
committed
Merge pull request #420 from myint/master
Support Python 3.5
2 parents 99efd5a + d48eef0 commit 151758c

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ python:
66
- 3.2
77
- 3.3
88
- 3.4
9+
- nightly
910
- pypy
1011
- pypy3
1112
install:

pep8.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,13 @@ def _is_eol_token(token, _eol_token=_is_eol_token):
13141314
_checks = {'physical_line': {}, 'logical_line': {}, 'tree': {}}
13151315

13161316

1317+
def _get_parameters(function):
1318+
if sys.version_info >= (3, 3):
1319+
return list(inspect.signature(function).parameters)
1320+
else:
1321+
return inspect.getargspec(function)[0]
1322+
1323+
13171324
def register_check(check, codes=None):
13181325
"""Register a new check object."""
13191326
def _add_check(check, kind, codes, args):
@@ -1322,13 +1329,13 @@ def _add_check(check, kind, codes, args):
13221329
else:
13231330
_checks[kind][check] = (codes or [''], args)
13241331
if inspect.isfunction(check):
1325-
args = inspect.getargspec(check)[0]
1332+
args = _get_parameters(check)
13261333
if args and args[0] in ('physical_line', 'logical_line'):
13271334
if codes is None:
13281335
codes = ERRORCODE_REGEX.findall(check.__doc__ or '')
13291336
_add_check(check, args[0], codes, args)
13301337
elif inspect.isclass(check):
1331-
if inspect.getargspec(check.__init__)[0][:2] == ['self', 'tree']:
1338+
if _get_parameters(check.__init__)[:2] == ['self', 'tree']:
13321339
_add_check(check, 'tree', codes, None)
13331340

13341341

@@ -1504,7 +1511,7 @@ def check_ast(self):
15041511
"""Build the file's AST and run all AST checks."""
15051512
try:
15061513
tree = compile(''.join(self.lines), '', 'exec', PyCF_ONLY_AST)
1507-
except (SyntaxError, TypeError):
1514+
except (ValueError, SyntaxError, TypeError):
15081515
return self.report_invalid_syntax()
15091516
for name, cls, __ in self._ast_checks:
15101517
checker = cls(tree, self.filename)

testsuite/test_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ def test_check_nullbytes(self):
339339
if 'SyntaxError' in stdout:
340340
# PyPy 2.2 returns a SyntaxError
341341
expected = "stdin:1:2: E901 SyntaxError"
342+
elif 'ValueError' in stdout:
343+
# Python 3.5.
344+
expected = "stdin:1:1: E901 ValueError"
342345
else:
343346
expected = "stdin:1:1: E901 TypeError"
344347
self.assertTrue(stdout.startswith(expected),

0 commit comments

Comments
 (0)