[3.13] gh-69686: Remove untrue part of __import__ replacement docs (GH-143261) (#143282)

gh-69686: Remove untrue part of `__import__` replacement docs (GH-143261)

Remove untrue part of `__import__` replacement docs

The original statement effectively says that replacing `__import__` at global scope affects import statements, and not only that, but only import statements within the rest of the executing module. None of that has been true since at least Python 2.7, I think.

This was likely missed in python/cpython#69686.
(cherry picked from commit 79c03ac001)

Co-authored-by: Thanos <111999343+Sachaa-Thanasius@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-12-30 06:22:47 +01:00 committed by GitHub
parent 93cb42fcb9
commit 7fc3aa5575
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -834,9 +834,7 @@ entirely with a custom meta path hook.
If it is acceptable to only alter the behaviour of import statements
without affecting other APIs that access the import system, then replacing
the builtin :func:`__import__` function may be sufficient. This technique
may also be employed at the module level to only alter the behaviour of
import statements within that module.
the builtin :func:`__import__` function may be sufficient.
To selectively prevent the import of some modules from a hook early on the
meta path (rather than disabling the standard import system entirely),