diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-08-16 21:59:20 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-08-16 21:59:20 -0400 |
commit | 79282728f4200919e9444e7789d45e3af03e86cf (patch) | |
tree | 84b783686999395f5415940d2c7a3b173f3cd47f /coverage/control.py | |
parent | e5f9d774506fa3b39b95e10b10967ee80e0607d9 (diff) | |
download | python-coveragepy-git-79282728f4200919e9444e7789d45e3af03e86cf.tar.gz |
Keep things working on PyPy 2.1
_structseq is in the lib_pypy directory on sys.path, but for some reason
when imported, it claims to be from
/opt/pypy//pypy-c-jit-linux-x86-64/build/lib_pypy/_structseq.py
I don't know why that is, but importing _structseq and treating its
directory as part of the stdlib makes the tests pass.
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/coverage/control.py b/coverage/control.py index 8821bfbb..98e4e78b 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -17,6 +17,14 @@ from coverage.results import Analysis, Numbers from coverage.summary import SummaryReporter from coverage.xmlreport import XmlReporter +# Pypy has some unusual stuff in the "stdlib". Consider those locations +# when deciding where the stdlib is. +try: + import _structseq # pylint: disable=F0401 +except ImportError: + _structseq = None + + class coverage(object): """Programmatic access to coverage.py. @@ -158,8 +166,8 @@ class coverage(object): # environments (virtualenv, for example), these modules may be # spread across a few locations. Look at all the candidate modules # we've imported, and take all the different ones. - for m in (atexit, os, random, socket): - if hasattr(m, "__file__"): + for m in (atexit, os, random, socket, _structseq): + if m is not None and hasattr(m, "__file__"): m_dir = self._canonical_dir(m) if m_dir not in self.pylib_dirs: self.pylib_dirs.append(m_dir) |