summaryrefslogtreecommitdiffstats
path: root/Python/fileutils.c
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2022-01-27 14:00:23 (GMT)
committerGitHub <noreply@github.com>2022-01-27 14:00:23 (GMT)
commit5c39e474dbd61397c2ff877fa17d742bf4646702 (patch)
treef00bf954704134375e4db9f38aab21b3bcc6e03e /Python/fileutils.c
parent89db09029566cf3af04b540e33fe1ff9b32f8c8b (diff)
downloadcpython-5c39e474dbd61397c2ff877fa17d742bf4646702.zip
cpython-5c39e474dbd61397c2ff877fa17d742bf4646702.tar.gz
cpython-5c39e474dbd61397c2ff877fa17d742bf4646702.tar.bz2
[3.10] bpo-45703: Invalidate _NamespacePath cache on importlib.invalidate_cache (GH-29384) (GH-30922)
Consider the following directory structure: . └── PATH1 └── namespace └── sub1 └── __init__.py And both PATH1 and PATH2 in sys path: $ PYTHONPATH=PATH1:PATH2 python3.11 >>> import namespace >>> import namespace.sub1 >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace']) >>> ... While this interpreter still runs, PATH2/namespace/sub2 is created: . ├── PATH1 │ └── namespace │ └── sub1 │ └── __init__.py └── PATH2 └── namespace └── sub2 └── __init__.py The newly created module cannot be imported: >>> ... >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace']) >>> import namespace.sub2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'namespace.sub2' Calling importlib.invalidate_caches() now newly allows to import it: >>> import importlib >>> importlib.invalidate_caches() >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace']) >>> import namespace.sub2 >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace', '.../PATH2/namespace']) This was not previously possible.
Diffstat (limited to 'Python/fileutils.c')
0 files changed, 0 insertions, 0 deletions