git » qt5-webengine.git » main » tree

[main] / python3.12-imp.patch

Description: stop using imp module which was removed in Python 3.12
Origin: upstream, commits
 https://chromium.googlesource.com/chromium/src/+/9e0c89a3b5638ba2
 https://chromium.googlesource.com/chromium/src/+/f5f6e361d037c316
Last-Update: 2024-03-17

--- a/components/resources/protobufs/binary_proto_generator.py
+++ b/components/resources/protobufs/binary_proto_generator.py
@@ -9,7 +9,7 @@
 """
 from __future__ import print_function
 import abc
-import imp
+from importlib import util as imp_util
 import optparse
 import os
 import re
@@ -68,7 +68,11 @@ class GoogleProtobufModuleImporter:
       raise ImportError(fullname)
 
     filepath = self._fullname_to_filepath(fullname)
-    return imp.load_source(fullname, filepath)
+    spec = imp_util.spec_from_file_location(fullname, filepath)
+    loaded = imp_util.module_from_spec(spec)
+    spec.loader.exec_module(loaded)
+
+    return loaded
 
 class BinaryProtoGenerator:
 
--- a/mojo/public/tools/mojom/mojom/fileutil.py
+++ b/mojo/public/tools/mojom/mojom/fileutil.py
@@ -3,7 +3,6 @@
 # found in the LICENSE file.
 
 import errno
-import imp
 import os.path
 import sys
 
--- a/mojo/public/tools/mojom/mojom/parse/lexer.py
+++ b/mojo/public/tools/mojom/mojom/parse/lexer.py
@@ -2,7 +2,6 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import imp
 import os.path
 import sys