diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-13 22:59:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 22:59:02 (GMT) |
commit | 51b533ec5049593dc009383226f935cf5181484c (patch) | |
tree | 7610ad3d42316413f4a6346ceb5aea1935a80fed /Tools | |
parent | 27426d89835ef6e2f28c5b48d553826daa01120b (diff) | |
download | cpython-51b533ec5049593dc009383226f935cf5181484c.zip cpython-51b533ec5049593dc009383226f935cf5181484c.tar.gz cpython-51b533ec5049593dc009383226f935cf5181484c.tar.bz2 |
[3.12] gh-98040: Fix importbench: use types.ModuleType() (GH-105743) (#105754)
gh-98040: Fix importbench: use types.ModuleType() (GH-105743)
Replace removed imp.new_module(name) with types.ModuleType(name).
(cherry picked from commit 457a459c7804950d4c27a243b176eb933ec87a06)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/importbench/importbench.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Tools/importbench/importbench.py b/Tools/importbench/importbench.py index 619263b..0c4b3bc 100644 --- a/Tools/importbench/importbench.py +++ b/Tools/importbench/importbench.py @@ -15,6 +15,7 @@ import py_compile import sys import tabnanny import timeit +import types def bench(name, cleanup=lambda: None, *, seconds=1, repeat=3): @@ -40,7 +41,7 @@ def bench(name, cleanup=lambda: None, *, seconds=1, repeat=3): def from_cache(seconds, repeat): """sys.modules""" name = '<benchmark import>' - module = imp.new_module(name) + module = types.ModuleType(name) module.__file__ = '<test>' module.__package__ = '' with util.uncache(name): |