diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-11-06 15:51:44 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-11-06 16:16:04 -0500 |
commit | 556344babd5210c093eba547d1b15489843f4359 (patch) | |
tree | 5ea9c3f84044722f116ebbfad4bb66cda91b8a87 /coverage/parser.py | |
parent | faaf0d45abcf0a11c9e5db144c5b79f581dd92eb (diff) | |
download | python-coveragepy-git-556344babd5210c093eba547d1b15489843f4359.tar.gz |
refactor: no need for special handling of compiling unicode source
This was a holdover from Python 2 days.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index c4fef9ce..135a3b18 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -15,7 +15,7 @@ from coverage.bytecode import code_objects from coverage.debug import short_stack from coverage.exceptions import NoSource, NotPython, _StopEverything from coverage.misc import contract, join_regex, new_contract, nice_pair, one_of -from coverage.phystokens import compile_unicode, generate_tokens, neuter_encoding_declaration +from coverage.phystokens import generate_tokens class PythonParser: @@ -359,7 +359,7 @@ class ByteParser: self.code = code else: try: - self.code = compile_unicode(text, filename, "exec") + self.code = compile(text, filename, "exec") except SyntaxError as synerr: raise NotPython( "Couldn't parse '%s' as Python source: '%s' at line %d" % ( @@ -624,17 +624,13 @@ class NodeList: # TODO: the cause messages have too many commas. # TODO: Shouldn't the cause messages join with "and" instead of "or"? -def ast_parse(text): - """How we create an AST parse.""" - return ast.parse(neuter_encoding_declaration(text)) - class AstArcAnalyzer: """Analyze source text with an AST to find executable code paths.""" @contract(text='unicode', statements=set) def __init__(self, text, statements, multiline): - self.root_node = ast_parse(text) + self.root_node = ast.parse(text) # TODO: I think this is happening in too many places. self.statements = {multiline.get(l, l) for l in statements} self.multiline = multiline |