"return None" -> "pass"

Python 3.4 classes have what looks like a return None, but this
is invalid syntax. So for now we'll remove all "return None"s.

There may be a "pass" in there instead.
This commit is contained in:
rocky
2016-07-13 13:37:07 -04:00
parent 6a125d49d8
commit 723ba1365f
2 changed files with 3 additions and 2 deletions

View File

@@ -2068,9 +2068,10 @@ class SourceWalker(GenericASTTraversal, object):
if self.hide_internal: if self.hide_internal:
if len(tokens) >= 2 and not noneInNames: if len(tokens) >= 2 and not noneInNames:
if tokens[-1].type == 'RETURN_VALUE': if tokens[-1].type == 'RETURN_VALUE':
# Should we also check for returning None? # Python 3.4's classes can add a "return None" which is
# invalid syntax.
if tokens[-2].type == 'LOAD_CONST': if tokens[-2].type == 'LOAD_CONST':
if isTopLevel: if isTopLevel or tokens[-2].pattr is None:
del tokens[-2:] del tokens[-2:]
else: else:
tokens.append(Token('RETURN_LAST')) tokens.append(Token('RETURN_LAST'))