summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-03-14 13:40:14 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-03-14 13:40:14 -0400
commit50a3baf54146337172d5efc57933adceb2b2fb78 (patch)
tree8ca9cee690bcbffd0c29f9b6978490dbda07589b /coverage/control.py
parentde73882e515fcce4bc4f2c62f0a6de42178866a5 (diff)
downloadpython-coveragepy-50a3baf54146337172d5efc57933adceb2b2fb78.tar.gz
Minimal IronPython support.
IronPython is weird: 2.7.7 has "str is unicode", and unicode.encode produces unicode! f_lasti is missing, and frame globals are missing.
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/coverage/control.py b/coverage/control.py
index d42cbdc..4cc7645 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -393,6 +393,10 @@ class Coverage(object):
can't be determined, None is returned.
"""
+ if module_globals is None: # pragma: only ironpython
+ # IronPython doesn't provide globals: https://github.com/IronLanguages/main/issues/1296
+ module_globals = {}
+
dunder_name = module_globals.get('__name__', None)
if isinstance(dunder_name, str) and dunder_name != '__main__':
@@ -441,7 +445,7 @@ class Coverage(object):
# .pyc files can be moved after compilation (for example, by being
# installed), we look for __file__ in the frame and prefer it to the
# co_filename value.
- dunder_file = frame.f_globals.get('__file__')
+ dunder_file = frame.f_globals and frame.f_globals.get('__file__')
if dunder_file:
filename = source_for_file(dunder_file)
if original_filename and not original_filename.startswith('<'):