Partial fix for removing singleton expr reduction

This commit is contained in:
rocky
2017-12-06 20:21:00 -05:00
parent a4e9410c07
commit 3d277270a4

View File

@@ -661,9 +661,8 @@ class SourceWalker(GenericASTTraversal, object):
def is_return_none(self, node):
# Is there a better way?
ret = (node[0] == 'ret_expr'
and node[0][0] == 'expr'
and node[0][0][0] == 'LOAD_CONST'
and node[0][0][0].pattr is None)
and node[0][0]== 'LOAD_CONST'
and node[0][0].pattr is None)
if self.version <= 2.6:
return ret
else:
@@ -2329,10 +2328,10 @@ class SourceWalker(GenericASTTraversal, object):
# than fight (with the grammar to not emit "return None").
if self.hide_internal:
if len(tokens) >= 2 and not noneInNames:
if tokens[-1].kind in ('RETURN_VALUE', 'RETURN_VALUE_LAMBDA'):
if tokens[-1] in ('RETURN_VALUE', 'RETURN_VALUE_LAMBDA'):
# Python 3.4's classes can add a "return None" which is
# invalid syntax.
if tokens[-2].kind == 'LOAD_CONST':
if tokens[-2] == 'LOAD_CONST':
if isTopLevel or tokens[-2].pattr is None:
del tokens[-2:]
else: