wrapper: replace usage of deprecated imp module for Python 3

A warning is emitted

  DeprecationWarning: the imp module is deprecated in favour of
  importlib; see the module's documentation for alternative uses

Change-Id: I6c5a9e024a9a904e02a24331f615548be3fe5f8e
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/230984
Reviewed-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
David Pursehouse 2019-07-11 13:07:42 +09:00
parent f7c51606f0
commit 1126c4ed86

View File

@ -15,7 +15,12 @@
# limitations under the License. # limitations under the License.
from __future__ import print_function from __future__ import print_function
import imp try:
from importlib.machinery import SourceFileLoader
_loader = lambda *args: SourceFileLoader(*args).load_module()
except ImportError:
import imp
_loader = lambda *args: imp.load_source(*args)
import os import os
@ -26,5 +31,5 @@ _wrapper_module = None
def Wrapper(): def Wrapper():
global _wrapper_module global _wrapper_module
if not _wrapper_module: if not _wrapper_module:
_wrapper_module = imp.load_source('wrapper', WrapperPath()) _wrapper_module = _loader('wrapper', WrapperPath())
return _wrapper_module return _wrapper_module