diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-05-21 23:04:09 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-05-21 23:04:09 -0400 |
commit | 762d67689a8ddc88195cdbb0787bc3e940ddbf85 (patch) | |
tree | 63297afbf892571db6b6b4a78c092478c5898639 /coverage/parser.py | |
parent | 51e42b3e3c0f92568a8e058189585c2baf3ca4ff (diff) | |
download | python-coveragepy-git-762d67689a8ddc88195cdbb0787bc3e940ddbf85.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.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index b090f02d..d883df46 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. |