diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-12-28 10:09:09 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-12-28 10:09:09 -0500 |
commit | d0e95e510f5fa73f81fc9a2ed6fc4f925f6c6460 (patch) | |
tree | d4340465e8520402d316eae289d20536ed1b545a /coverage/parser.py | |
parent | 3ca6fdd609eea353f89fa7047d85d6b48f2af68f (diff) | |
download | python-coveragepy-d0e95e510f5fa73f81fc9a2ed6fc4f925f6c6460.tar.gz |
Further consolidation of code reading Python source.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 14 |
1 files changed, 7 insertions, 7 deletions
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. |