mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
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.
Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
Automerge-Triggered-By: GH:encukou
|
||
|---|---|---|
| .. | ||
| clinic | ||
| _warnings.c | ||
| asdl.c | ||
| ast.c | ||
| ast_opt.c | ||
| ast_unparse.c | ||
| bltinmodule.c | ||
| bootstrap_hash.c | ||
| ceval.c | ||
| ceval_gil.h | ||
| codecs.c | ||
| compile.c | ||
| condvar.h | ||
| context.c | ||
| dtoa.c | ||
| dup2.c | ||
| dynamic_annotations.c | ||
| dynload_aix.c | ||
| dynload_dl.c | ||
| dynload_hpux.c | ||
| dynload_shlib.c | ||
| dynload_stub.c | ||
| dynload_win.c | ||
| errors.c | ||
| fileutils.c | ||
| formatter_unicode.c | ||
| frozen.c | ||
| frozenmain.c | ||
| future.c | ||
| getargs.c | ||
| getcompiler.c | ||
| getcopyright.c | ||
| getopt.c | ||
| getplatform.c | ||
| getversion.c | ||
| graminit.c | ||
| hamt.c | ||
| hashtable.c | ||
| import.c | ||
| importdl.c | ||
| importdl.h | ||
| importlib.h | ||
| importlib_external.h | ||
| importlib_zipimport.h | ||
| initconfig.c | ||
| makeopcodetargets.py | ||
| marshal.c | ||
| modsupport.c | ||
| mysnprintf.c | ||
| mystrtoul.c | ||
| opcode_targets.h | ||
| pathconfig.c | ||
| peephole.c | ||
| preconfig.c | ||
| pyarena.c | ||
| pyctype.c | ||
| pyfpe.c | ||
| pyhash.c | ||
| pylifecycle.c | ||
| pymath.c | ||
| pystate.c | ||
| pystrcmp.c | ||
| pystrhex.c | ||
| pystrtod.c | ||
| Python-ast.c | ||
| pythonrun.c | ||
| pytime.c | ||
| README | ||
| strdup.c | ||
| structmember.c | ||
| symtable.c | ||
| sysmodule.c | ||
| thread.c | ||
| thread_nt.h | ||
| thread_pthread.h | ||
| traceback.c | ||
| wordcode_helpers.h | ||
Miscellaneous source files for the main Python shared library