Python 2.7 "return None" bug

Same as 2.3-2.6 "return None".
This commit is contained in:
rocky
2016-09-03 10:27:21 -04:00
parent 75c718bc5c
commit 8f95ec9882
2 changed files with 9 additions and 7 deletions

Binary file not shown.

View File

@@ -774,17 +774,19 @@ class SourceWalker(GenericASTTraversal, object):
def is_return_none(self, node):
# Is there a better way?
if self.version <= 2.6:
return (node == 'return_stmt'
ret = (node == 'return_stmt'
and node[0] == 'ret_expr'
and node[0][0] == 'expr'
and node[0][0][0] == 'LOAD_CONST'
and node[0][0][0].pattr is None)
if self.version <= 2.6:
return ret
else:
# FIXME: should the AST expression be folded into
# the global RETURN_NONE constant?
return (ret or
node == AST('return_stmt',
[AST('ret_expr', [NONE]), Token('RETURN_VALUE')])
[AST('ret_expr', [NONE]), Token('RETURN_VALUE')]))
def n_return_stmt(self, node):
if self.params['isLambda']: