--- a/DebugClients/Python/coverage/__init__.py Fri Apr 04 22:57:07 2014 +0200 +++ b/DebugClients/Python/coverage/__init__.py Thu Apr 10 23:02:20 2014 +0200 @@ -5,20 +5,19 @@ """ -__version__ = "3.2" # see detailed history in CHANGES.txt +from .version import __version__, __url__ -__url__ = "http://nedbatchelder.com/code/coverage" - -from .control import coverage +from .control import coverage, process_startup from .data import CoverageData from .cmdline import main, CoverageScript from .misc import CoverageException - # Module-level functions. The original API to this module was based on # functions defined directly in the module, with a singleton of the coverage() -# class. That design hampered programmability. Here we define the top-level -# functions to create the singleton when they are first called. +# class. That design hampered programmability, so the current api uses +# explicitly-created coverage objects. But for backward compatibility, here we +# define the top-level functions to create the singleton when they are first +# called. # Singleton object for use with module-level functions. The singleton is # created as needed when one of the module-level functions is called. @@ -31,12 +30,34 @@ called. """ + # Disable pylint msg W0612, because a bunch of variables look unused, but + # they're accessed via locals(). + # pylint: disable=W0612 + def wrapper(*args, **kwargs): """Singleton wrapper around a coverage method.""" global _the_coverage if not _the_coverage: _the_coverage = coverage(auto_data=True) return getattr(_the_coverage, name)(*args, **kwargs) + + import inspect + meth = getattr(coverage, name) + args, varargs, kw, defaults = inspect.getargspec(meth) + argspec = inspect.formatargspec(args[1:], varargs, kw, defaults) + docstring = meth.__doc__ + wrapper.__doc__ = ("""\ + A first-use-singleton wrapper around coverage.%(name)s. + + This wrapper is provided for backward compatibility with legacy code. + New code should use coverage.%(name)s directly. + + %(name)s%(argspec)s: + + %(docstring)s + """ % locals() + ) + return wrapper @@ -52,10 +73,26 @@ annotate = _singleton_method('annotate') +# On Windows, we encode and decode deep enough that something goes wrong and +# the encodings.utf_8 module is loaded and then unloaded, I don't know why. +# Adding a reference here prevents it from being unloaded. Yuk. +import encodings.utf_8 + +# Because of the "from .control import fooey" lines at the top of the +# file, there's an entry for coverage.coverage in sys.modules, mapped to None. +# This makes some inspection tools (like pydoc) unable to find the class +# coverage.coverage. So remove that entry. +import sys +try: + del sys.modules['coverage.coverage'] +except KeyError: + pass + + # COPYRIGHT AND LICENSE # # Copyright 2001 Gareth Rees. All rights reserved. -# Copyright 2004-2009 Ned Batchelder. All rights reserved. +# Copyright 2004-2013 Ned Batchelder. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -81,6 +118,3 @@ # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. - -# -# eflag: FileType = Python2