From 90ecf09e3fc3f9c8950deba71fca699c7623edbf Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 3 Aug 2016 13:03:01 -0400 Subject: Add support for PyPy3 5.2 alpha 1 --- coverage/control.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index 56a6afd6..16e9748a 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -35,11 +35,20 @@ from coverage.xmlreport import XmlReporter os = isolate_module(os) # Pypy has some unusual stuff in the "stdlib". Consider those locations -# when deciding where the stdlib is. -try: - import _structseq -except ImportError: - _structseq = None +# when deciding where the stdlib is. This modules are not used for anything, +# they are modules importable from the pypy lib directories, so that we can +# find those directories. +_structseq = _pypy_irc_topic = None +if env.PYPY: + try: + import _structseq + except ImportError: + pass + + try: + import _pypy_irc_topic + except ImportError: + pass class Coverage(object): @@ -308,9 +317,10 @@ 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, inspect, os, platform, re, _structseq, traceback): + for m in (atexit, inspect, os, platform, _pypy_irc_topic, re, _structseq, traceback): if m is not None and hasattr(m, "__file__"): self.pylib_dirs.add(self._canonical_dir(m)) + if _structseq and not hasattr(_structseq, '__file__'): # PyPy 2.4 has no __file__ in the builtin modules, but the code # objects still have the file names. So dig into one to find -- cgit v1.2.1