mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
wrapper.py: Replacing load_module() with exec_module()
Fixed "DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead." in wrapper.py. Additionally removed Python 2 code (imp.load_source()). Test: tox Signed-off-by: Daniel Kutik <daniel.kutik@lavawerk.com> Change-Id: Ib7cc19b1c545f6449e034c4b01b582cf6cf4b581 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353237 Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
35af2f8daf
commit
50a2c0e368
14
wrapper.py
14
wrapper.py
@ -12,12 +12,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
try:
|
import importlib.machinery
|
||||||
from importlib.machinery import SourceFileLoader
|
import importlib.util
|
||||||
_loader = lambda *args: SourceFileLoader(*args).load_module()
|
|
||||||
except ImportError:
|
|
||||||
import imp
|
|
||||||
_loader = lambda *args: imp.load_source(*args)
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
@ -31,5 +27,9 @@ _wrapper_module = None
|
|||||||
def Wrapper():
|
def Wrapper():
|
||||||
global _wrapper_module
|
global _wrapper_module
|
||||||
if not _wrapper_module:
|
if not _wrapper_module:
|
||||||
_wrapper_module = _loader('wrapper', WrapperPath())
|
modname = 'wrapper'
|
||||||
|
loader = importlib.machinery.SourceFileLoader(modname, WrapperPath())
|
||||||
|
spec = importlib.util.spec_from_loader(modname, loader)
|
||||||
|
_wrapper_module = importlib.util.module_from_spec(spec)
|
||||||
|
loader.exec_module(_wrapper_module)
|
||||||
return _wrapper_module
|
return _wrapper_module
|
||||||
|
Loading…
Reference in New Issue
Block a user