diff options
author | Barry Warsaw <barry@python.org> | 2023-04-28 23:17:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 23:17:58 (GMT) |
commit | e1f14643dc0e6024f8df9ae975c3b05912a3cb28 (patch) | |
tree | 00bb66f68cadb9457a2a9486873ecf13be0241d6 /Python/makeopcodetargets.py | |
parent | 79b9db9295a5a1607a0b4b10a8b4b72567eaf1ef (diff) | |
download | cpython-e1f14643dc0e6024f8df9ae975c3b05912a3cb28.zip cpython-e1f14643dc0e6024f8df9ae975c3b05912a3cb28.tar.gz cpython-e1f14643dc0e6024f8df9ae975c3b05912a3cb28.tar.bz2 |
gh-98040: Remove just the `imp` module (#98573)
Diffstat (limited to 'Python/makeopcodetargets.py')
-rwxr-xr-x | Python/makeopcodetargets.py | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/Python/makeopcodetargets.py b/Python/makeopcodetargets.py index 5aa3180..2b402ae 100755 --- a/Python/makeopcodetargets.py +++ b/Python/makeopcodetargets.py @@ -7,24 +7,18 @@ import os import sys -try: - from importlib.machinery import SourceFileLoader -except ImportError: - import imp - - def find_module(modname): - """Finds and returns a module in the local dist/checkout. - """ - modpath = os.path.join( - os.path.dirname(os.path.dirname(__file__)), "Lib") - return imp.load_module(modname, *imp.find_module(modname, [modpath])) -else: - def find_module(modname): - """Finds and returns a module in the local dist/checkout. - """ - modpath = os.path.join( - os.path.dirname(os.path.dirname(__file__)), "Lib", modname + ".py") - return SourceFileLoader(modname, modpath).load_module() +# 2023-04-27(warsaw): Pre-Python 3.12, this would catch ImportErrors and try to +# import imp, and then use imp.load_module(). The imp module was removed in +# Python 3.12 (and long deprecated before that), and it's unclear under what +# conditions this import will now fail, so the fallback was simply removed. +from importlib.machinery import SourceFileLoader + +def find_module(modname): + """Finds and returns a module in the local dist/checkout. + """ + modpath = os.path.join( + os.path.dirname(os.path.dirname(__file__)), "Lib", modname + ".py") + return SourceFileLoader(modname, modpath).load_module() def write_contents(f): |