From 4361522532396635a593a3892dedd8955848d250 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 2 Jan 2016 11:19:45 -0500 Subject: Coding declarations are a pain in the ass --HG-- branch : ast-branch --- coverage/parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index fc631fcc..262a78e3 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -17,7 +17,7 @@ from coverage.backward import bytes_to_ints, string_class from coverage.bytecode import ByteCodes, CodeObjects from coverage.misc import contract, nice_pair, join_regex from coverage.misc import CoverageException, NoSource, NotPython -from coverage.phystokens import compile_unicode, generate_tokens +from coverage.phystokens import compile_unicode, generate_tokens, neuter_encoding_declaration class PythonParser(object): @@ -324,8 +324,9 @@ class TryBlock(object): class AstArcAnalyzer(object): + @contract(text='unicode') def __init__(self, text): - self.root_node = ast.parse(text) + self.root_node = ast.parse(neuter_encoding_declaration(text)) if int(os.environ.get("COVERAGE_ASTDUMP", 0)): # Dump the AST so that failing tests have helpful output. ast_dump(self.root_node) -- cgit v1.2.1