summaryrefslogtreecommitdiff
path: root/coverage/parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-05-21 23:04:09 -0400
committerNed Batchelder <ned@nedbatchelder.com>2010-05-21 23:04:09 -0400
commit88eef7d43f1056d8ff65ca260fa7f28e49f4bfc1 (patch)
tree363a616f3c0ed47d2cbf1a497f7c7e167a0b5e60 /coverage/parser.py
parentccc8aba7b5244fbc8051fe1b8d664aed3dba7d64 (diff)
downloadpython-coveragepy-88eef7d43f1056d8ff65ca260fa7f28e49f4bfc1.tar.gz
Fail early, and with an intelligible message, if the current Python implementation can't analyze code.
Diffstat (limited to 'coverage/parser.py')
-rw-r--r--coverage/parser.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index b090f02..d883df4 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -306,6 +306,16 @@ class ByteParser(object):
(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.
+ for attr in ['co_lnotab', 'co_firstlineno', 'co_consts', 'co_code']:
+ if not hasattr(self.code, attr):
+ raise CoverageException(
+ "This implementation of Python doesn't support code "
+ "analysis.\n"
+ "Run coverage.py under CPython for this command."
+ )
+
def child_parsers(self):
"""Iterate over all the code objects nested within this one.