Commit 4c102b58 authored by serge-sans-paille's avatar serge-sans-paille
Browse files

Bug 1857516 - Get rid of deprecated imp python module in favor of importlib CLOSED TREE a=pascalc

parent 6e88e059
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
# 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 io
import json
import os
@@ -12,7 +11,7 @@ import tempfile
import unittest

import mozpack.path as mozpath
from mozfile import NamedTemporaryFile
from mozfile import NamedTemporaryFile, load_source
from mozunit import MockedOpen, main
from mozwebidlcodegen import WebIDLCodegenManager, WebIDLCodegenManagerState

@@ -242,7 +241,7 @@ class TestWebIDLCodegenManager(unittest.TestCase):
        with NamedTemporaryFile("wt") as fh:
            fh.write("# Original content")
            fh.flush()
            mod = imp.load_source("mozwebidlcodegen.fakemodule", fh.name)
            mod = load_source("mozwebidlcodegen.fakemodule", fh.name)
            mod.__file__ = fake_path

            args = self._get_manager_args()
+2 −4
Original line number Diff line number Diff line
@@ -4,11 +4,10 @@

import codecs
import encodings.idna
import imp
import os
import re
import sys
from make_dafsa import words_to_cxx, words_to_bin

from make_dafsa import words_to_bin, words_to_cxx

"""
Processes a file containing effective TLD data.  See the following URL for a
@@ -22,7 +21,6 @@ http://wiki.mozilla.org/Gecko:Effective_TLD_Service

def getEffectiveTLDs(path):
    file = codecs.open(path, "r", "UTF-8")
    entries = []
    domains = set()
    for line in file:
        # line always contains a line terminator unless the file is empty
+5 −3
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
# 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])]
+3 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ from mach.decorators import (
    SettingsProvider,
    SubCommand,
)
from mozfile import load_source
from voluptuous import All, Boolean, Required, Schema

import mozbuild.settings  # noqa need @SettingsProvider hook to execute
@@ -1099,11 +1100,10 @@ def android_gtest(

    # run gtest via remotegtests.py
    exit_code = 0
    import imp

    path = os.path.join("testing", "gtest", "remotegtests.py")
    with open(path, "r") as fh:
        imp.load_module("remotegtests", fh, path, (".py", "r", imp.PY_SOURCE))
    load_source("remotegtests", path)

    import remotegtests

    tester = remotegtests.RemoteGTests()
Loading