45 lines
1.5 KiB
Diff
45 lines
1.5 KiB
Diff
From e0e1d87b81c6d32b6facdfb5d2249b860444802a Mon Sep 17 00:00:00 2001
|
|
From: Peter Varga <pvarga@inf.u-szeged.hu>
|
|
Date: Fri, 08 Dec 2023 15:11:25 +0100
|
|
Subject: [PATCH] [Backport] Replace imp.load_source with importlib equivalent.
|
|
|
|
The imp module has been deprecated for years and the function
|
|
load_source was even removed from the documentation long ago.
|
|
|
|
It will be removed in Python 3.12, which will be part of Fedora
|
|
version 39, due in late October 2023.
|
|
|
|
Pick-to: 112-based 108-based
|
|
Bug: 1487454
|
|
Change-Id: I0acdb22b81f3921dc25afd3d95e9013e1b8f8099
|
|
Review-URL: https://chromium-review.googlesource.com/c/chromium/src/+/4894238
|
|
Cr-Commit-Position: refs/heads/main@{#1214660}
|
|
---
|
|
|
|
diff --git a/chromium/components/resources/protobufs/binary_proto_generator.py b/chromium/components/resources/protobufs/binary_proto_generator.py
|
|
index 2a1802d..8b9de65 100755
|
|
--- a/chromium/components/resources/protobufs/binary_proto_generator.py
|
|
+++ b/chromium/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 @@
|
|
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:
|
|
|