mirror of
https://github.com/python/cpython.git
synced 2025-11-27 13:45:25 +00:00
gh-98040: Fix importbench: use types.ModuleType() (#105743)
Replace removed imp.new_module(name) with types.ModuleType(name).
This commit is contained in:
parent
757b402ea1
commit
457a459c78
2 changed files with 4 additions and 1 deletions
|
|
@ -1369,6 +1369,8 @@ Removed
|
||||||
* The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in
|
* The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in
|
||||||
:gh:`98040`.)
|
:gh:`98040`.)
|
||||||
|
|
||||||
|
* Replace ``imp.new_module(name)`` with ``types.ModuleType(name)``.
|
||||||
|
|
||||||
* Removed the ``suspicious`` rule from the documentation Makefile, and
|
* Removed the ``suspicious`` rule from the documentation Makefile, and
|
||||||
removed ``Doc/tools/rstlint.py``, both in favor of `sphinx-lint
|
removed ``Doc/tools/rstlint.py``, both in favor of `sphinx-lint
|
||||||
<https://github.com/sphinx-contrib/sphinx-lint>`_.
|
<https://github.com/sphinx-contrib/sphinx-lint>`_.
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import py_compile
|
||||||
import sys
|
import sys
|
||||||
import tabnanny
|
import tabnanny
|
||||||
import timeit
|
import timeit
|
||||||
|
import types
|
||||||
|
|
||||||
|
|
||||||
def bench(name, cleanup=lambda: None, *, seconds=1, repeat=3):
|
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):
|
def from_cache(seconds, repeat):
|
||||||
"""sys.modules"""
|
"""sys.modules"""
|
||||||
name = '<benchmark import>'
|
name = '<benchmark import>'
|
||||||
module = imp.new_module(name)
|
module = types.ModuleType(name)
|
||||||
module.__file__ = '<test>'
|
module.__file__ = '<test>'
|
||||||
module.__package__ = ''
|
module.__package__ = ''
|
||||||
with util.uncache(name):
|
with util.uncache(name):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue