diff options
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 700c3ebd..62ca495f 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -3,10 +3,8 @@ """Add things to old Pythons so I can pretend they are newer.""" -# This file does lots of tricky stuff, so disable a bunch of pylint warnings. -# pylint: disable=redefined-builtin +# This file does tricky stuff, so disable a pylint warning. # pylint: disable=unused-import -# pxlint: disable=no-name-in-module import sys @@ -19,11 +17,14 @@ try: except ImportError: from io import StringIO -# In py3, ConfigParser was renamed to the more-standard configparser +# In py3, ConfigParser was renamed to the more-standard configparser. +# But there's a py3 backport that installs "configparser" in py2, and I don't +# want it because it has annoying deprecation warnings. So try the real py2 +# import first. try: - import configparser -except ImportError: import ConfigParser as configparser +except ImportError: + import configparser # What's a string called? try: @@ -45,9 +46,9 @@ except ImportError: # range or xrange? try: - range = xrange + range = xrange # pylint: disable=redefined-builtin except NameError: - range = range # pylint: disable=redefined-variable-type + range = range # shlex.quote is new, but there's an undocumented implementation in "pipes", # who knew!? @@ -143,6 +144,12 @@ except AttributeError: PYC_MAGIC_NUMBER = imp.get_magic() +def invalidate_import_caches(): + """Invalidate any import caches that may or may not exist.""" + if importlib and hasattr(importlib, "invalidate_caches"): + importlib.invalidate_caches() + + def import_local_file(modname, modfile=None): """Import a local file as a module. |