summaryrefslogtreecommitdiff
path: root/coverage/parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-12-28 10:09:09 -0500
committerNed Batchelder <ned@nedbatchelder.com>2014-12-28 10:09:09 -0500
commit93561c76f281656169e5c062d93bc30da95d8c94 (patch)
treeac5a824337730c134d9e822bc63aa2a4ce98414c /coverage/parser.py
parent98a7b99ed97af0f5dfc6fc7f5219ad4b026a6dfc (diff)
downloadpython-coveragepy-git-93561c76f281656169e5c062d93bc30da95d8c94.tar.gz
Further consolidation of code reading Python source.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r--coverage/parser.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index b50bc578..05c0d0c2 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.