cpython/Python
Petr Viktorin 8d239bfdcc
[3.9] bpo-45703: Invalidate _NamespacePath cache on importlib.invalidate_cache (GH-29384) (GH-30922) (GH-31076)
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
2022-02-02 05:50:43 -08:00
..
clinic bpo-39489: Remove COUNT_ALLOCS special build (GH-18259) 2020-02-03 15:17:15 +01:00
Python-ast.c [3.9] bpo-11105: Do not crash when compiling recursive ASTs (GH-20594) (GH-26522) 2021-06-03 22:22:34 +01:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
_warnings.c [3.9] bpo-40998: Fix a refleak in create_filter() (GH-23365) (GH-23369) 2020-11-18 09:45:29 -08:00
asdl.c replace PY_SIZE_MAX with SIZE_MAX 2016-09-07 09:26:18 -07:00
ast.c [3.9] bpo-45461: Fix IncrementalDecoder and StreamReader in the "unicode-escape" codec (GH-28939) (GH-28945) 2021-10-14 20:03:29 +03:00
ast_opt.c bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503) 2020-04-22 23:29:27 +01:00
ast_unparse.c bpo-40663: Correctly handle annotations with subscripts in ast_unparse.c (GH-20156) 2020-05-18 19:23:48 +01:00
bltinmodule.c bpo-44856: Possible reference leak in error paths of update_bases() and __build_class__ (GH-27647) (GH-27651) 2021-08-07 13:17:41 +02:00
bootstrap_hash.c [3.9] Remove trailing spaces (GH-28710) 2021-10-03 20:04:38 +03:00
ceval.c [3.9] bpo-45806: Fix recovery from stack overflow for 3.9. Again. (GH-29640) 2021-11-19 19:51:50 +01:00
ceval_gil.h [3.9] bpo-40514: Remove --with-experimental-isolated-subinterpreters in 3.9 (GH-20228) 2020-05-20 00:27:46 +02:00
codecs.c bpo-40268: Remove a few pycore_pystate.h includes (GH-19510) 2020-04-14 17:52:15 +02:00
compile.c Set line number of END_ASYNC_FOR so that it doesn't show in traces. (GH-27255) 2021-07-20 12:09:56 +02:00
condvar.h Typo fix: "throuhgh" should be "through". (GH-16704) 2019-10-10 20:43:13 -07:00
context.c bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769) 2020-04-29 02:29:20 +02:00
dtoa.c bpo-40780: Fix failure of _Py_dg_dtoa to remove trailing zeros (GH-20435) (GH-20514) 2020-05-29 14:46:54 +01:00
dup2.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
dynamic_annotations.c bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748) 2017-12-12 13:55:04 +02:00
dynload_aix.c bpo-41894: Fix UnicodeDecodeError while loading native module (GH-22466) 2020-10-14 19:25:45 -07:00
dynload_dl.c Issue #24268: Fix import naming when loading extension modules. Patch by Petr Viktorin. 2015-05-23 14:13:41 -07:00
dynload_hpux.c bpo-44959: Add fallback to extension modules with '.sl' suffix on HP-UX (GH-27857) 2021-10-22 04:08:50 -07:00
dynload_shlib.c bpo-41894: Fix UnicodeDecodeError while loading native module (GH-22466) 2020-10-14 19:25:45 -07:00
dynload_stub.c Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py. 2012-05-04 15:20:40 -04:00
dynload_win.c bpo-43499: Silence compiler warnings about using legacy C API on Windows (GH-24873) 2021-03-16 08:03:37 +02:00
errors.c [3.9] bpo-45806: Fix recovery from stack overflow for 3.9. Again. (GH-29640) 2021-11-19 19:51:50 +01:00
fileutils.c [3.9] Fix typos in the Python directory (GH-28767) (GH-28798) 2021-10-07 07:36:39 -07:00
formatter_unicode.c bpo-28146: Fix a confusing error message in str.format() (GH-24213) 2021-05-13 14:35:30 -07:00
frozen.c bpo-36540: PEP 570 -- Implementation (GH-12701) 2019-04-29 13:36:57 +01:00
frozenmain.c bpo-40268: Remove a few pycore_pystate.h includes (GH-19510) 2020-04-14 17:52:15 +02:00
future.c bpo-34683: Make SyntaxError column offsets consistently 1-indexed (gh-9338) 2018-09-24 14:12:49 -07:00
getargs.c bpo-36346: Add Py_DEPRECATED to deprecated unicode APIs (GH-20878) 2020-06-18 17:30:53 +09:00
getcompiler.c closes bpo-31696: don't mention GCC in sys.version when building with clang (#3891) 2017-10-05 21:15:14 -07:00
getcopyright.c Update copyright year to 2022. (GH-30335) 2022-01-02 12:34:36 -08:00
getopt.c bpo-40527: Fix command line argument parsing (GH-19955) 2020-05-06 22:22:17 +09:00
getplatform.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
getversion.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
graminit.c bpo-39702: Relax grammar restrictions on decorators (PEP 614) (GH-18570) 2020-03-03 14:25:44 -08:00
hamt.c bpo-40268: Remove unused structmember.h includes (GH-19530) 2020-04-15 02:35:41 +02:00
hashtable.c bpo-41061: Fix incorrect expressions in hashtable (GH-21028) 2020-06-22 01:01:48 -07:00
import.c [3.9] bpo-44050: Extension modules can share state when they don't support sub-interpreters. (GH-27794) (GH-28741) 2021-10-05 22:30:25 +02:00
importdl.c Fix format string in _PyImport_LoadDynamicModuleWithSpec() (GH-28863) 2021-10-12 10:10:41 -07:00
importdl.h PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
importlib.h [3.9] bpo-41076: Pre-feed the parser with the f-string expression location (GH-21054) (GH-21190) 2020-06-28 01:15:28 +01:00
importlib_external.h [3.9] bpo-45703: Invalidate _NamespacePath cache on importlib.invalidate_cache (GH-29384) (GH-30922) (GH-31076) 2022-02-02 05:50:43 -08:00
importlib_zipimport.h [3.9] bpo-40924: Revert "bpo-39791 native hooks for importlib.resources.files (GH-20576)" (#20760) 2020-06-09 19:50:01 +02:00
initconfig.c [3.9] Fix typos in the Python directory (GH-28767) (GH-28798) 2021-10-07 07:36:39 -07:00
makeopcodetargets.py makeopcodetargets.py: we need to import Lib/opcode.py 2016-03-26 01:04:37 +01:00
marshal.c bpo-41180: Replace marshal code.__new__ audit event with marshal.load[s] and marshal.dumps (GH-26971) 2021-06-30 18:52:39 +01:00
modsupport.c closes bpo-41533: Fix a potential memory leak when allocating a stack (GH-21847) 2020-09-04 15:56:04 -07:00
mysnprintf.c bpo-36020: Remove snprintf macro in pyerrors.h (GH-20889) 2020-06-15 13:20:10 -07:00
mystrtoul.c bpo-37752: Delete redundant Py_CHARMASK in normalizestring() (GH-15095) 2019-09-10 17:04:08 +01:00
opcode_targets.h bpo-39320: Handle unpacking of **values in compiler (GH-18141) 2020-01-27 09:57:45 +00:00
pathconfig.c [3.9] Fix typos in the Python directory (GH-28767) (GH-28798) 2021-10-07 07:36:39 -07:00
peephole.c bpo-42057: Fix peephole optimizer (GH-22802) 2020-10-22 11:06:07 +09:00
preconfig.c [3.9] bpo-40514: Remove --with-experimental-isolated-subinterpreters in 3.9 (GH-20228) 2020-05-20 00:27:46 +02:00
pyarena.c bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264) 2019-03-13 22:59:55 +02:00
pyctype.c
pyfpe.c bpo-29137: Remove fpectl module (#4789) 2018-01-05 23:15:34 -08:00
pyhash.c bpo-40602: Add _Py_HashPointerRaw() function (GH-20056) 2020-05-12 18:46:20 +02:00
pylifecycle.c bpo-40998: Address compiler warnings found by ubsan (GH-20929) 2020-11-18 08:01:48 -08:00
pymath.c bpo-31031: Unify duplicate bits_in_digit and bit_length (GH-2866) 2020-01-16 15:09:19 +01:00
pystate.c [3.9] bpo-42540: reallocation of id_mutex should not force default allocator (GH-29564) (GH-29600) 2021-11-17 23:53:33 +01:00
pystrcmp.c bpo-41524: fix pointer bug in PyOS_mystr{n}icmp (GH-21845) (GH-21978) 2020-08-30 15:53:09 +09:00
pystrhex.c bpo-40313: speed up bytes.hex() (GH-19594) 2020-04-20 17:17:52 -07:00
pystrtod.c bpo-35081: Move dtoa.h header to the internal C API (GH-18489) 2020-02-12 22:54:42 +01:00
pythonrun.c bpo-45614: Fix traceback display for exceptions with invalid module name (GH-29726) (GH-29827) 2021-11-29 10:11:48 +00:00
pytime.c [3.9] Remove trailing spaces (GH-28710) 2021-10-03 20:04:38 +03:00
strdup.c bpo-36623: Clean parser headers and include files (GH-12253) 2019-04-13 17:05:14 +01:00
structmember.c bpo-40268: Remove unused structmember.h includes (GH-19530) 2020-04-15 02:35:41 +02:00
symtable.c bpo-40268: Remove unused structmember.h includes (GH-19530) 2020-04-15 02:35:41 +02:00
sysmodule.c [3.9] bpo-45806: Fix recovery from stack overflow for 3.9. Again. (GH-29640) 2021-11-19 19:51:50 +01:00
thread.c bpo-40268: Remove explicit pythread.h includes (#19529) 2020-04-15 02:04:42 +02:00
thread_nt.h bpo-41299: Reduce lag in Windows threading timeouts by using a higher precision time source (GH-26568) 2021-06-11 15:03:10 -07:00
thread_pthread.h bpo-41710: PyThread_acquire_lock_timed() uses sem_clockwait() (GH-28671) (GH-28683) 2021-10-01 18:51:15 +02:00
traceback.c bpo-45831: _Py_DumpASCII() uses a single write() call if possible (GH-29596) (GH-29597) 2021-11-17 22:59:42 +01:00
wordcode_helpers.h bpo-31338 (#3374) 2017-09-14 18:13:16 -07:00

README

Miscellaneous source files for the main Python shared library