From: Victor Stinner Date: Tue, 13 Jun 2023 22:32:12 +0000 (+0200) Subject: gh-98040: Fix importbench: use types.ModuleType() (#105743) X-Git-Tag: v3.13.0a1~1765 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=457a459c7804950d4c27a243b176eb933ec87a06;p=thirdparty%2FPython%2Fcpython.git gh-98040: Fix importbench: use types.ModuleType() (#105743) Replace removed imp.new_module(name) with types.ModuleType(name). --- diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index bfbc6c7a35c6..1e063ed7d226 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -1369,6 +1369,8 @@ Removed * The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in :gh:`98040`.) + * Replace ``imp.new_module(name)`` with ``types.ModuleType(name)``. + * Removed the ``suspicious`` rule from the documentation Makefile, and removed ``Doc/tools/rstlint.py``, both in favor of `sphinx-lint `_. diff --git a/Tools/importbench/importbench.py b/Tools/importbench/importbench.py index 619263b553c0..0c4b3bc73517 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 = '' - module = imp.new_module(name) + module = types.ModuleType(name) module.__file__ = '' module.__package__ = '' with util.uncache(name):