diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-16 07:32:09 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-16 07:32:09 -0400 |
commit | 2ea433dff7f3454a68d167d2429f9b2d1fe17c57 (patch) | |
tree | 1c8d9eff7dffb3fcac093bf0a4944c3730d0204f /coverage/backward.py | |
parent | 7efac0451c9a8e2068302e2fd47913d57e00be5f (diff) | |
download | python-coveragepy-2ea433dff7f3454a68d167d2429f9b2d1fe17c57.tar.gz |
Refactor execfile to avoid imp to avoid deprecation warnings
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index e81dd19..8d72811 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -1,10 +1,11 @@ """Add things to old Pythons so I can pretend they are newer.""" # This file does lots of tricky stuff, so disable a bunch of lintisms. -# pylint: disable=F0401,W0611,W0622 -# F0401: Unable to import blah -# W0611: Unused import blah -# W0622: Redefining built-in blah +# pylint: disable=redefined-builtin +# pylint: disable=import-error +# pylint: disable=no-member +# pylint: disable=unused-import +# pylint: disable=no-name-in-module import os, re, sys @@ -124,3 +125,23 @@ try: except ImportError: import md5 md5 = md5.new + + +# imp was deprecated in Python 3.4 +try: + import importlib, importlib.util + imp = None +except ImportError: + importlib = None + +# we only want to use importlib if it has everything we need. +try: + importlib.util.find_spec +except Exception: + import imp + importlib = None + +try: + PYC_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER +except AttributeError: + PYC_MAGIC_NUMBER = imp.get_magic() |