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 | 5be7d2919268934795ca27e7740e6e0641480d6c (patch) | |
tree | 09ed9b4f85329bcd8ba41e813533a65162ea9c79 /coverage/backward.py | |
parent | f373746d5f19532c2fc690313fc13be0641eb0f6 (diff) | |
download | python-coveragepy-git-5be7d2919268934795ca27e7740e6e0641480d6c.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 e81dd199..8d728117 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() |