8000 [3.12] gh-104212: Explain how to port imp code to importlib (GH-10590… · python/cpython@5729b41 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 5729b41

Browse files
[3.12] gh-104212: Explain how to port imp code to importlib (GH-105905) (#105952)
gh-104212: Explain how to port imp code to importlib (GH-105905) (cherry picked from commit 7a56a41) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent c5c8111 commit 5729b41

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

Doc/whatsnew/3.12.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,38 @@ Removed
13681368
* The :mod:`!imp` module has been removed. (Contributed by Barry Warsaw in
13691369
:gh:`98040`.)
13701370

1371-
* Replace ``imp.new_module(name)`` with ``types.ModuleType(name)``.
1371+
* Replace removed :mod:`!imp` functions with :mod:`importlib` functions:
1372+
1373+
================================= =======================================
1374+
imp importlib
1375+
================================= =======================================
1376+
``imp.NullImporter`` Insert ``None`` into ``sys.path_importer_cache``
1377+
``imp.cache_from_source()`` :func:`importlib.util.cache_from_source`
1378+
``imp.find_module()`` :func:`importlib.util.find_spec`
1379+
``imp.get_magic()`` :attr:`importlib.util.MAGIC_NUMBER`
1380+
``imp.get_suffixes()`` :attr:`importlib.machinery.SOURCE_SUFFIXES`, :attr:`importlib.machinery.EXTENSION_SUFFIXES`, and :attr:`importlib.machinery.BYTECODE_SUFFIXES`
1381+
``imp.get_tag()`` :attr:`sys.implementation.cache_tag <sys.implementation>`
1382+
``imp.load_module()`` :func:`importlib.import_module`
1383+
``imp.new_module(name)`` ``types.ModuleType(name)``
1384+
``imp.reload()`` :func:`importlib.reload`
1385+
``imp.source_from_cache()`` :func:`importlib.util.source_from_cache`
1386+
================================= =======================================
1387+
1388+
* Removed :mod:`!imp` functions and attributes with no replacements:
1389+
1390+
* undocumented functions:
1391+
1392+
* ``imp.init_builtin()``
1393+
* ``imp.load_compiled()``
1394+
* ``imp.load_dynamic()``
1395+
* ``imp.load_package()``
1396+
* ``imp.load_source()``
1397+
1398+
* ``imp.lock_held()``, ``imp.acquire_lock()``, ``imp.release_lock()``:
1399+
the locking scheme has changed in Python 3.3 to per-module locks.
1400+
* ``imp.find_module()`` constants: ``SEARCH_ERROR``, ``PY_SOURCE``,
1401+
``PY_COMPILED``, ``C_EXTENSION``, ``PY_RESOURCE``, ``PKG_DIRECTORY``,
1402+
``C_BUILTIN``, ``PY_FROZEN``, ``PY_CODERESOURCE``, ``IMP_HOOK``.
13721403

13731404
* Removed the ``suspicious`` rule from the documentation Makefile, and
13741405
removed ``Doc/tools/rstlint.py``, both in favor of `sphinx-lint

0 commit comments

Comments
 (0)
0