From 35bea86c9fcf897428b4d0b3c1e935b7e1312075 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Wed, 15 Jul 2015 14:07:43 -0700 Subject: [PATCH] No Starred node type on Python 2 --- _pytest/assertion/newinterpret.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/_pytest/assertion/newinterpret.py b/_pytest/assertion/newinterpret.py index ff20082dc..d8e741162 100644 --- a/_pytest/assertion/newinterpret.py +++ b/_pytest/assertion/newinterpret.py @@ -33,6 +33,12 @@ else: def _is_ast_stmt(node): return isinstance(node, ast.stmt) +try: + _Starred = ast.Starred +except AttributeError: + # Python 2. Define a dummy class so isinstance() will always be False. + class _Starred(object): pass + class Failure(Exception): """Error found while interpreting AST.""" @@ -232,7 +238,7 @@ class DebugInterpreter(ast.NodeVisitor): arguments = [] for arg in call.args: arg_explanation, arg_result = self.visit(arg) - if type(arg) is ast.Starred: + if isinstance(arg, _Starred): arg_name = "__exprinfo_star" ns[arg_name] = arg_result arguments.append("*%s" % (arg_name,))