From 88eef7d43f1056d8ff65ca260fa7f28e49f4bfc1 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 21 May 2010 23:04:09 -0400 Subject: Fail early, and with an intelligible message, if the current Python implementation can't analyze code. --- coverage/parser.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'coverage/parser.py') 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. -- cgit v1.2.1