summaryrefslogtreecommitdiffstats
path: root/python/mach
diff options
context:
space:
mode:
Diffstat (limited to 'python/mach')
-rw-r--r--python/mach/mach/main.py8
-rw-r--r--python/mach/mach/test/test_entry_point.py4
2 files changed, 7 insertions, 5 deletions
diff --git a/python/mach/mach/main.py b/python/mach/mach/main.py
index 9ab880341d..6c32ce2058 100644
--- a/python/mach/mach/main.py
+++ b/python/mach/mach/main.py
@@ -8,16 +8,18 @@
import argparse
import codecs
import errno
-import imp
import logging
import os
import sys
import traceback
+import types
import uuid
from collections.abc import Iterable
from pathlib import Path
from typing import Dict, List, Union
+from mozfile import load_source
+
from .base import (
CommandContext,
FailedCommandError,
@@ -267,13 +269,13 @@ To see more help for a specific command, run:
# Ensure parent module is present otherwise we'll (likely) get
# an error due to unknown parent.
if "mach.commands" not in sys.modules:
- mod = imp.new_module("mach.commands")
+ mod = types.ModuleType("mach.commands")
sys.modules["mach.commands"] = mod
module_name = f"mach.commands.{uuid.uuid4().hex}"
try:
- imp.load_source(module_name, str(path))
+ load_source(module_name, str(path))
except IOError as e:
if e.errno != errno.ENOENT:
raise
diff --git a/python/mach/mach/test/test_entry_point.py b/python/mach/mach/test/test_entry_point.py
index 1129eba476..11aa083cda 100644
--- a/python/mach/mach/test/test_entry_point.py
+++ b/python/mach/mach/test/test_entry_point.py
@@ -1,8 +1,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import imp
import sys
+import types
from pathlib import Path
from unittest.mock import patch
@@ -38,7 +38,7 @@ class TestEntryPoints(TestBase):
# Ensure parent module is present otherwise we'll (likely) get
# an error due to unknown parent.
if "mach.commands" not in sys.modules:
- mod = imp.new_module("mach.commands")
+ mod = types.ModuleType("mach.commands")
sys.modules["mach.commands"] = mod
mock.return_value = [Entry([self.provider_dir])]