Skip to content

Commit

Permalink
Revert "[py3.12] [tools] Remove imp usage"
Browse files Browse the repository at this point in the history
This reverts commit 27c222d.

Reason for revert: Suspected cause of b/308216872

Original change's description:
> [py3.12] [tools] Remove imp usage
>
> And use its equivalent instead.
>
> Bug: 1487454
> Change-Id: Ie78c266106bd1f9a29fd8bd3394f233e90d330e0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4983816
> Commit-Queue: Ho Cheung <uioptt24@gmail.com>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Cr-Commit-Position: refs/heads/main@{#1216473}

Bug: 1487454
Change-Id: If22b3a404dacd45b3c14a111c55d586499a107a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4988601
Commit-Queue: Nic Hollingum <hollingum@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Nic Hollingum <hollingum@google.com>
Cr-Commit-Position: refs/heads/main@{#1216729}
  • Loading branch information
Nic Hollingum authored and Chromium LUCI CQ committed Oct 30, 2023
1 parent c996a96 commit ca00966
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
6 changes: 2 additions & 4 deletions tools/perf/core/find_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import collections
import fnmatch
import importlib.util
import imp
import logging
import os
import sys
Expand Down Expand Up @@ -53,10 +53,8 @@ def FindPythonDependencies(module_path):
try:
# Load the module to inherit its sys.path modifications.
sys.path.insert(0, os.path.abspath(os.path.dirname(module_path)))
spec = importlib.util.spec_from_file_location(
imp.load_source(
os.path.splitext(os.path.basename(module_path))[0], module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

# Analyze the module for its imports.
graph = modulegraph.ModuleGraph()
Expand Down
9 changes: 3 additions & 6 deletions tools/sublime/ninja_options_script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand All @@ -16,18 +16,15 @@

from __future__ import print_function

import importlib.util
import imp
import optparse
import os
import shlex

ycm_module_path = os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../vim/chromium.ycm_extra_conf.py'))
spec = importlib.util.spec_from_file_location("ycm_extra_conf", ycm_module_path)
ycm_extra_conf = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ycm_extra_conf)

ycm_extra_conf = imp.load_source('ycm_extra_conf', ycm_module_path)

def main():
usage = "usage: %prog [options] file"
Expand Down
8 changes: 3 additions & 5 deletions tools/vim/tests/chromium.ycm_extra_conf_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
PATH. Due to these requirements, the tests should only be run on upload.
"""

import importlib.util
import imp
import os
import shutil
import stat
Expand Down Expand Up @@ -123,10 +123,8 @@ def setUp(self):
sys.path.append(os.path.join(self.actual_chrome_root, 'tools', 'vim'))
self.test_data_path = os.path.join(self.actual_chrome_root, 'tools', 'vim',
'tests', 'data')
ycm_extra_conf_spec = importlib.util.spec_from_file_location(
'ycm_extra_conf', 'chromium.ycm_extra_conf.py')
self.ycm_extra_conf = importlib.util.module_from_spec(ycm_extra_conf_spec)
ycm_extra_conf_spec.loader.exec_module(self.ycm_extra_conf)
self.ycm_extra_conf = imp.load_source('ycm_extra_conf',
'chromium.ycm_extra_conf.py')
self.test_root = tempfile.mkdtemp()
self.SetUpFakeChromeTreeBelowPath()

Expand Down

0 comments on commit ca00966

Please sign in to comment.