summaryrefslogtreecommitdiffstats
path: root/testing/mozbase
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
commitf3bcaf9f88aad2c423ebcd61121562f9834187d4 (patch)
treef22238c29b57707b645a350940e3e9bdf3ce1f5d /testing/mozbase
parentAdding debian version 115.7.0esr-1~deb12u1. (diff)
downloadfirefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.tar.xz
firefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.zip
Merging upstream version 115.8.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozbase')
-rw-r--r--testing/mozbase/mozfile/mozfile/mozfile.py14
-rw-r--r--testing/mozbase/mozprofile/mozprofile/prefs.py14
2 files changed, 25 insertions, 3 deletions
diff --git a/testing/mozbase/mozfile/mozfile/mozfile.py b/testing/mozbase/mozfile/mozfile/mozfile.py
index 1f4ffa74af..20d56fe4b2 100644
--- a/testing/mozbase/mozfile/mozfile/mozfile.py
+++ b/testing/mozbase/mozfile/mozfile/mozfile.py
@@ -22,6 +22,7 @@ __all__ = [
"extract",
"is_url",
"load",
+ "load_source",
"copy_contents",
"match",
"move",
@@ -629,6 +630,19 @@ def load(resource):
return urllib.request.urlopen(resource)
+# see https://docs.python.org/3/whatsnew/3.12.html#imp
+def load_source(modname, filename):
+ import importlib.machinery
+ import importlib.util
+
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ sys.modules[module.__name__] = module
+ loader.exec_module(module)
+ return module
+
+
# We can't depend on mozpack.path here, so copy the 'match' function over.
re_cache = {}
diff --git a/testing/mozbase/mozprofile/mozprofile/prefs.py b/testing/mozbase/mozprofile/mozprofile/prefs.py
index 6c3b1173c8..b84d531f23 100644
--- a/testing/mozbase/mozprofile/mozprofile/prefs.py
+++ b/testing/mozbase/mozprofile/mozprofile/prefs.py
@@ -12,7 +12,15 @@ import tokenize
import mozfile
import six
from six import StringIO, string_types
-from six.moves.configparser import SafeConfigParser as ConfigParser
+
+try:
+ from six.moves.configparser import SafeConfigParser as ConfigParser
+except ImportError: # SafeConfigParser was removed in 3.12
+ from configparser import ConfigParser
+try:
+ ConfigParser.read_file
+except AttributeError: # read_file was added in 3.2, readfp removed in 3.12
+ ConfigParser.read_file = ConfigParser.readfp
if six.PY3:
@@ -24,7 +32,7 @@ __all__ = ("PreferencesReadError", "Preferences")
class PreferencesReadError(Exception):
- """read error for prefrences files"""
+ """read error for preferences files"""
class Preferences(object):
@@ -124,7 +132,7 @@ class Preferences(object):
parser = ConfigParser()
parser.optionxform = str
- parser.readfp(mozfile.load(path))
+ parser.read_file(mozfile.load(path))
if section:
if section not in parser.sections():