From d0e95e510f5fa73f81fc9a2ed6fc4f925f6c6460 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 28 Dec 2014 10:09:09 -0500 Subject: Further consolidation of code reading Python source. --- coverage/parser.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index b50bc57..05c0d0c 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -56,11 +56,10 @@ class PythonParser(CodeParser): if self.text: assert isinstance(self.text, str) # Scrap the BOM if it exists. - if ord(self.text[0]) == 0xfeff: - self.text = self.text[1:] - # Python source should always have a final newline. - if self.text[-1] != "\n": - self.text += "\n" + # (Used to do this, but no longer. Not sure what bad will happen + # if we don't do it.) + # if ord(self.text[0]) == 0xfeff: + # self.text = self.text[1:] self.exclude = exclude @@ -352,9 +351,10 @@ class ByteParser(object): self.code = compile(text, filename, "exec") except SyntaxError as synerr: raise NotPython( - "Couldn't parse '%s' as Python source: '%s' at line %d" % - (filename, synerr.msg, synerr.lineno) + "Couldn't parse %r as Python source: '%s' at line %d" % ( + filename, synerr.msg, synerr.lineno ) + ) # Alternative Python implementations don't always provide all the # attributes on code objects that we need to do the analysis. -- cgit v1.2.1