Skip to content

Commit

Permalink
Stop using deprecated imp.load_source
Browse files Browse the repository at this point in the history
imp module has been removed from python 3.12.

b/312559511
  • Loading branch information
isarkis authored Nov 22, 2023
1 parent fbfbaa7 commit 259c141
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cobalt/bindings/v8c/_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
#
"""Ask the parent directory to load the project environment."""

from imp import load_source # pylint: disable=deprecated-module
import importlib.util
import importlib.machinery
from os import path
import sys

_ENV = path.abspath(path.join(path.dirname(__file__), path.pardir, '_env.py'))
if not path.exists(_ENV):
print(f'{__file__}: Can\'t find repo root.\nMissing parent: {_ENV}')
sys.exit(1)
load_source('', _ENV)
loader = importlib.machinery.SourceFileLoader('', _ENV)
spec = importlib.util.spec_from_file_location('', _ENV, loader=loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)

0 comments on commit 259c141

Please sign in to comment.