use NameConstant node when it exists (fixes #735)

--HG--
branch : issue735
This commit is contained in:
Benjamin Peterson 2015-06-03 18:07:10 -05:00
parent a2bb2ff164
commit f3ad2e4ad2
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,8 @@
2.8.0.dev (compared to 2.7.X)
-----------------------------
- fix issue735: assertion failures on debug versions of Python 3.4+
- change test module importing behaviour to append to sys.path
instead of prepending. This better allows to run test modules
against installated versions of a package even if the package

View File

@ -442,6 +442,13 @@ binop_map = {
ast.NotIn: "not in"
}
# Python 3.4+ compatibility
if hasattr(ast, "NameConstant"):
_NameConstant = ast.NameConstant
else:
def _NameConstant(c):
return ast.Name(str(c), ast.Load())
def set_location(node, lineno, col_offset):
"""Set node location information recursively."""
@ -680,7 +687,7 @@ class AssertionRewriter(ast.NodeVisitor):
if self.variables:
variables = [ast.Name(name, ast.Store())
for name in self.variables]
clear = ast.Assign(variables, ast.Name("None", ast.Load()))
clear = ast.Assign(variables, _NameConstant(None))
self.statements.append(clear)
# Fix line numbers.
for stmt in self.statements: