Jason R. Coombs
3e0fec7e07
Sync with importlib_metadata 6.5 (GH-103584)
2023-04-20 22:12:48 -04:00
Ned Batchelder
1aa376f946
Remove double space in import error message ( #103458 )
2023-04-14 00:45:14 -07:00
Mark Shannon
411b169281
GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython (GH-103083)
...
* The majority of the monitoring code is in instrumentation.c
* The new instrumentation bytecodes are in bytecodes.c
* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
2023-04-12 12:04:55 +01:00
Brett Cannon
5d08c3ff7d
GH-102700: allow built-in modules to be submodules (GH-103162)
2023-04-06 14:19:54 -07:00
Brandt Bucher
b4978ff872
GH-88691: Shrink the CALL caches (GH-103230)
2023-04-05 14:15:49 -07:00
Brandt Bucher
121057aa36
GH-89987: Shrink the BINARY_SUBSCR caches (GH-103022)
2023-03-29 15:53:30 -07:00
Brandt Bucher
0444ae2487
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801)
2023-03-23 15:25:09 -07:00
Irit Katriel
3468c768ce
gh-102859: Remove JUMP_IF_FALSE_OR_POP and JUMP_IF_TRUE_OR_POP ( #102870 )
2023-03-22 18:10:48 +00:00
Brandt Bucher
08b67fb34f
GH-90997: Shrink the LOAD_GLOBAL caches ( #102569 )
2023-03-10 17:01:16 -08:00
Alex Waygood
401d7a7f00
gh-102515: Remove unused imports in the `Lib/` directory ( #102516 )
2023-03-08 11:45:38 +00:00
Jason R. Coombs
5170caf305
gh-97930: Apply changes from importlib_resources 5.12. (GH-102010)
2023-02-18 16:29:22 -05:00
Dong-hee Na
f482ade4c7
gh-101766: Fix refleak for _BlockingOnManager resources from test suite level (gh-101988)
2023-02-18 00:18:47 +09:00
Dong-hee Na
775f8819e3
gh-101766: Fix refleak for _BlockingOnManager resources (gh-101942)
2023-02-17 19:14:07 +09:00
Irit Katriel
81e3aa835c
gh-101799: implement PREP_RERAISE_STAR as an intrinsic function ( #101800 )
2023-02-14 11:54:13 +00:00
Mark Shannon
160f2fe2b9
GH-87849: Simplify stack effect of SEND and specialize it for generators and coroutines. (GH-101788)
2023-02-13 11:24:55 +00:00
penguin_wwy
753fc8a5d6
gh-101632: Add the new RETURN_CONST opcode ( #101633 )
2023-02-07 22:32:21 +00:00
Brandt Bucher
6162a0e305
Fix incorrect versions in magic number comments (GH-101301)
2023-01-25 13:30:33 -08:00
Mark Shannon
f02fa64bf2
GH-100762: Don't call `gen.throw()` in `gen.close()`, unless necessary. (GH-101013)
...
* Store exception stack depth in YIELD_VALUE's oparg and use it avoid expensive gen.throw() in gen.close() where possible.
2023-01-24 17:25:37 +00:00
Jean-Paul Calderone
3325f054e3
gh-91351: Fix some bugs in importlib handling of re-entrant imports (GH-94504)
...
Co-authored-by: Brett Cannon <brett@python.org>
2023-01-20 16:00:39 -08:00
Mark Shannon
7b14c2ef19
GH-100982: Add `COMPARE_AND_BRANCH` instruction (GH-100983)
2023-01-16 12:35:21 +00:00
Mark Shannon
6e4e14d98f
GH-100923: Embed jump mask in `COMPARE_OP` oparg (GH-100924)
2023-01-11 20:40:43 +00:00
Mark Shannon
78068126a1
GH-99005: More intrinsics (GH-100774)
...
* Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
2023-01-06 14:47:57 +00:00
Mark Shannon
28187141cc
GH-99005: Add `CALL_INTRINSIC_1` instruction (GH-100771)
...
* Remove PRINT_EXPR instruction
* Remove STOPITERATION_ERROR instruction
* Remove IMPORT_STAR instruction
2023-01-05 16:05:51 +00:00
Jason R. Coombs
447d061bc7
gh-97930: Apply changes from importlib_resources 5.10. (GH-100598)
2023-01-01 11:07:32 -05:00
Samet YASLAN
f10f503b24
gh-100585: Fixed a bug where importlib.resources.as_file was leaving file pointers open (GH-100586)
...
* gh-100585: Fixed open fp bug in the imporlib module
* Added news for gh-100585
2022-12-28 16:31:43 -05:00
Nikita Sobolev
c69cfcdb11
closes gh-99508: fix `TypeError` in `Lib/importlib/_bootstrap_external.py` (GH-99635)
2022-11-23 16:47:31 -06:00
Irit Katriel
3dd6ee2c00
gh-99254: remove all unused consts from code objects (GH-99255)
2022-11-11 10:53:43 +00:00
Anh71me
bd221c01dd
gh-98139: enhance namespace package repr
2022-11-06 22:13:40 +00:00
Mark Shannon
f4adb97506
GH-96793: Implement PEP 479 in bytecode. (GH-99006)
...
* Handle converting StopIteration to RuntimeError in bytecode.
* Add custom instruction for converting StopIteration into RuntimeError.
2022-11-03 11:38:51 +00:00
Mark Shannon
22863df7ca
GH-96793: Change `FOR_ITER` to not pop the iterator on exhaustion. (GH-96801)
...
Change FOR_ITER to have the same stack effect regardless of whether it branches or not.
Performance is unchanged as FOR_ITER (and specialized forms jump over the cleanup code).
2022-10-27 11:55:03 +01:00
Jason R. Coombs
cea910ebf1
gh-97930: Merge with importlib_resources 5.9 (GH-97929)
...
* Merge with importlib_resources 5.9
* Update changelog
2022-10-16 15:00:39 -04:00
Barry Warsaw
13d4489142
gh-86298: Ensure that __loader__ and __spec__.loader agree in warnings.warn_explicit() (GH-97803)
...
In `_warnings.c`, in the C equivalent of `warnings.warn_explicit()`, if the module globals are given (and not None), the warning will attempt to get the source line for the issued warning. To do this, it needs the module's loader.
Previously, it would only look up `__loader__` in the module globals. In https://github.com/python/cpython/issues/86298 we want to defer to the `__spec__.loader` if available.
The first step on this journey is to check that `loader == __spec__.loader` and issue another warning if it is not. This commit does that.
Since this is a PoC, only manual testing for now.
```python
# /tmp/foo.py
import warnings
import bar
warnings.warn_explicit(
'warning!',
RuntimeWarning,
'bar.py', 2,
module='bar knee',
module_globals=bar.__dict__,
)
```
```python
# /tmp/bar.py
import sys
import os
import pathlib
# __loader__ = pathlib.Path()
```
Then running this: `./python.exe -Wdefault /tmp/foo.py`
Produces:
```
bar.py:2: RuntimeWarning: warning!
import os
```
Uncomment the `__loader__ = ` line in `bar.py` and try it again:
```
sys:1: ImportWarning: Module bar; __loader__ != __spec__.loader (<_frozen_importlib_external.SourceFileLoader object at 0x109f7dfa0> != PosixPath('.'))
bar.py:2: RuntimeWarning: warning!
import os
```
Automerge-Triggered-By: GH:warsaw
2022-10-06 19:32:53 -07:00
Gregory P. Smith
27369ef56f
gh-82874: Convert remaining importlib format uses to f-str. ( #98005 )
...
f-yes
2022-10-06 18:27:51 -07:00
Nikita Sobolev
27025e158c
gh-97850: Remove deprecated functions from `importlib.utils` ( #97898 )
...
* gh-97850: Remove deprecated functions from `importlib.utils`
* Rebase and remove `set_package` from diff
2022-10-06 17:57:10 -07:00
Gregory P. Smith
683ab85955
bpo-38693: Use f-strings instead of str.format() within importlib ( #17058 )
...
This is a small performance improvement, especially for one or two hot
places such as _handle_fromlist() that are called a lot and the
.format() method was being used just to join two strings with a dot.
Otherwise it is merely a readability improvement.
We keep `_ERR_MSG` and `_ERR_MSG_PREFIX` as those may be used elsewhere for canonical looking error messages.
2022-10-06 16:43:16 -07:00
Brett Cannon
e1c4d56fdd
gh-65961: Do not rely solely on `__cached__` (GH-97990)
...
Make sure `__spec__.cached` (at minimum) can be used.
2022-10-06 15:40:22 -07:00
Jason R. Coombs
8af04cdef2
gh-97781: Apply changes from importlib_metadata 5. (GH-97785)
...
* gh-97781: Apply changes from importlib_metadata 5.
* Apply changes from upstream
* Apply changes from upstream.
2022-10-06 15:25:24 -04:00
Brett Cannon
c206e53bb7
gh-65961: Raise `DeprecationWarning` when `__package__` differs from `__spec__.parent` ( #97879 )
...
Also remove `importlib.util.set_package()` which was already slated for removal.
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2022-10-05 15:00:45 -07:00
Barry Warsaw
5dc3599135
gh-97850: Remove all known instances of module_repr() ( #97876 )
...
Remove all known instances of module_repr()
2022-10-05 11:42:26 -07:00
Irit Katriel
4c72517cad
gh-93554: Conditional jump opcodes only jump forward (GH-96318)
2022-09-01 21:36:47 +01:00
Brandt Bucher
5bfb3c372b
GH-90997: Wrap yield from/await in a virtual try/except StopIteration (GH-96010)
2022-08-19 12:33:44 -07:00
Barry Warsaw
e1182bc377
gh-94619: Remove long deprecated methods module_repr() and load_module() ( #94624 )
...
* gh-94619: Remove long deprecated methods module_repr() and load_module()
Closes #94619
* Update Misc/NEWS.d/next/Library/2022-07-06-14-57-33.gh-issue-94619.PRqKVX.rst
Fix typo
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
2022-08-04 17:24:26 -07:00
Thomas Grainger
6da988a46c
gh-91181: drop support for bytes on sys.path (GH-31934)
...
Support for bytes broke sometime between Python 3.2 and 3.6 and has been broken ever since. Trying to bring back supports is surprisingly difficult in the face of -b and checking for keys in sys.path_importer_cache. Since the support was broken for so long, trying to overcome the difficulty of bringing back the support has been deemed not worth it.
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
2022-07-16 18:07:53 -07:00
Irit Katriel
324d01944d
gh-94485: Set line number of module's RESUME instruction to 0, as specified by PEP 626 (GH-94552)
...
Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-07-05 14:38:44 +02:00
Jason R. Coombs
71848c9609
gh-93963: Officially deprecate abcs and warn about their usage. (GH-93965)
...
Fixes #93963
Automerge-Triggered-By: GH:jaraco
2022-07-03 12:17:27 -07:00
Mark Shannon
c0453a40fa
GH-94163: Add BINARY_SLICE and STORE_SLICE instructions. (GH-94168)
2022-06-27 12:24:23 +01:00
Jason R. Coombs
38612a05b5
gh-93259: Validate arg to ``Distribution.from_name``. (GH-94270)
...
Syncs with importlib_metadata 4.12.0.
2022-06-25 21:04:28 -04:00
Dennis Sweeney
5fcfdd87c9
GH-91432: Specialize FOR_ITER (GH-91713)
...
* Adds FOR_ITER_LIST and FOR_ITER_RANGE specializations.
* Adds _PyLong_AssignValue() internal function to avoid temporary boxing of ints.
2022-06-21 11:19:26 +01:00
Ken Jin
b083450f88
GH-93429: Merge `LOAD_METHOD` back into `LOAD_ATTR` (GH-93430)
2022-06-14 11:36:22 +01:00
Victor Stinner
443ca731d6
gh-93353: Fix importlib.resources._tempfile() finalizer ( #93377 )
...
Fix the importlib.resources.as_file() context manager to remove the
temporary file if destroyed late during Python finalization: keep a
local reference to the os.remove() function. Patch by Victor Stinner.
2022-06-13 19:24:00 +02:00
Christian Heimes
09243b898a
gh-93461: Invalidate sys.path_importer_cache entries with relative paths (GH-93653)
2022-06-10 23:56:26 +02:00
Mark Shannon
f012df706c
Shrink the LOAD_METHOD cache by one codeunit. ( #93537 )
2022-06-07 10:28:53 +01:00
Dennis Sweeney
f425f3bb27
gh-93143: Avoid NULL check in LOAD_FAST based on analysis in the compiler (GH-93144)
2022-05-31 16:32:30 -04:00
Mark Shannon
3fd8610002
GH-89914: Make the oparg of the YIELD_VALUE instruction equal the stack depth. (GH-92960)
2022-05-19 17:49:29 +01:00
Mark Shannon
e48ac9c100
GH-90690: Remove `PRECALL` instruction (GH-92925)
2022-05-19 11:05:26 +01:00
Dennis Sweeney
37c6db60f9
gh-91869: Fix tracing of specialized instructions with extended args (GH-91945)
2022-04-27 22:36:34 -06:00
Mark Shannon
944fffee89
GH-88116: Use a compact format to represent end line and column offsets. (GH-91666)
...
* Stores all location info in linetable to conform to PEP 626.
* Remove column table from code objects.
* Remove end-line table from code objects.
* Document new location table format
2022-04-21 16:10:37 +01:00
Jason R. Coombs
7659681556
gh-91298: Refine traversable (apply changes from importlib_resources 5.7.1) ( #91623 )
...
* bpo-47142: Refine traversable (apply changes from importlib_resources 5.7.1)
* Replace changelog referencing github issue.
2022-04-17 11:10:36 -04:00
Irit Katriel
ea2ae02607
gh-91276: Make JUMP_IF_TRUE_OR_POP/JUMP_IF_FALSE_OR_POP relative (GH-32215)
2022-04-15 20:19:24 +01:00
Irit Katriel
dd207a6ac5
bpo-47120: make POP_JUMP_IF_TRUE/FALSE/NONE/NOT_NONE relative (GH-32400)
2022-04-11 10:40:24 +01:00
Irit Katriel
0aa8d5cbd8
bpo-47120: make JUMP_NO_INTERRUPT relative (GH-32221)
2022-04-05 12:49:08 +01:00
Irit Katriel
32091df41c
bpo-47186: Replace JUMP_IF_NOT_EG_MATCH by CHECK_EG_MATCH + jump (GH-32309)
2022-04-05 12:06:22 +01:00
Irit Katriel
04e07c258f
bpo-47186: Replace JUMP_IF_NOT_EXC_MATCH by CHECK_EXC_MATCH + jump (GH-32231)
2022-04-01 13:59:38 +01:00
Irit Katriel
a00518d9ad
bpo-47120: Replace the JUMP_ABSOLUTE opcode by the relative JUMP_BACKWARD (GH-32115)
2022-03-31 14:14:15 +01:00
Mark Shannon
3011a097bd
Use low bit of LOAD_GLOBAL's oparg to indicate whether it should push an additional NULL. (GH-31933)
2022-03-17 16:14:57 +00:00
Jason R. Coombs
b1e2868607
bpo-47004: Sync with importlib_metadata 4.11.3. ( #31854 )
2022-03-13 15:53:29 -04:00
Brandt Bucher
5498a61c7c
bpo-46841: Don't use an oparg counter for `STORE_SUBSCR` (GH-31742)
2022-03-08 15:53:22 +00:00
Brandt Bucher
f193631387
bpo-46841: Use inline caching for calls (GH-31709)
2022-03-07 11:45:00 -08:00
Serhiy Storchaka
6927632492
Remove trailing spaces (GH-31695)
2022-03-05 17:47:00 +02:00
Brandt Bucher
586b24d3be
bpo-46841: Fix error message hacks in `GET_AWAITABLE` (GH-31664)
2022-03-04 12:41:17 +00:00
Brandt Bucher
05a8bc1c94
bpo-46841: Use inline caching for attribute accesses (GH-31640)
2022-03-03 15:31:00 -08:00
Mark Shannon
3b0f1c5a71
bpo-46841: Use inline cache for `BINARY_SUBSCR`. (GH-31618)
2022-03-01 16:00:34 +00:00
Brandt Bucher
7820a5897e
bpo-46841: Use inline caching for `COMPARE_OP` (GH-31622)
2022-03-01 13:53:13 +00:00
Mark Shannon
4558af5a8f
bpo-46841: Move the cache for `LOAD_GLOBAL` inline. (GH-31575)
2022-02-28 12:56:29 +00:00
Brandt Bucher
424ecab494
bpo-46841: Use inline caching for `UNPACK_SEQUENCE` (GH-31591)
2022-02-28 11:54:14 +00:00
Brandt Bucher
0f41aac109
bpo-46841: Use *inline* caching for `BINARY_OP` (GH-31543)
2022-02-25 12:11:34 +00:00
Mark Shannon
59585d6b2e
bpo-46329: Streamline calling sequence a bit. (GH-31465)
...
* Move handling of bound-methods to PRECALL.
* Remove call_shape.postcall_shrink
* Remove call_shape.callable
* Remove call_shape.callable. Change CALL oparg to match PRECALL oparg.
* Move KW_NAMES before PRECALL.
* Update opcode docs in dis.rst
2022-02-21 18:26:47 +00:00
Mark Shannon
cf345e945f
bpo-46329: Change calling sequence (again) (GH-31373)
...
* Change calling sequence: Add PUSH_NULL. Merge PRECALL_FUNCTION and PRECALL_METHOD into PRECALL.
2022-02-18 17:19:08 +00:00
Arie Bovenberg
dd76b3f7d3
bpo-46246: add missing __slots__ to importlib.metadata.DeprecatedList (GH-30452)
...
Confirmed with @jaraco that this indeed needs a fix.
A question that came up while I was digging into the code: I think `SelectableGroups` could similarly use `__slots__ = ()`, since its purpose seems only for convenience around `dict`, not to have attributes of its own.
Automerge-Triggered-By: GH:jaraco
2022-02-10 16:56:21 -08:00
Mark Shannon
89fd7c3452
bpo-46329: Split calls into precall and call instructions. (GH-30855)
...
* Add PRECALL_FUNCTION opcode.
* Move 'call shape' varaibles into struct.
* Replace CALL_NO_KW and CALL_KW with KW_NAMES and CALL instructions.
* Specialize for builtin methods taking using the METH_FASTCALL | METH_KEYWORDS protocol.
* Allow kwnames for specialized calls to builtin types.
* Specialize calls to tuple(arg) and str(arg).
2022-01-28 12:42:30 +00:00
Brandt Bucher
8548366864
bpo-46528: Simplify the VM's stack manipulations (GH-30902)
2022-01-26 12:47:45 -08:00
Mark Shannon
0367a36fdc
bpo-43683: Streamline YIELD_VALUE and SEND (GH-30723)
...
* Split YIELD_VALUE into ASYNC_GEN_WRAP; YIELD_VALUE for async generators.
* Split SEND into SEND; YIELD_VALUE.
* Document new opcodes.
2022-01-24 11:08:53 +00:00
Jason R. Coombs
51c3e28c8a
bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 4.10.1) (GH-30803)
2022-01-22 23:00:23 -05:00
Jason R. Coombs
443dec6c9a
bpo-46474: Apply changes from importlib_metadata 4.10.0 (GH-30802)
2022-01-22 21:39:00 -05:00
Mark Shannon
b04dfbbe4b
bpo-46409: Make generators in bytecode (GH-30633)
...
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes.
* Trim frame and generator by word each.
* Minor refactor of frame.c
* Update test.test_sys to account for smaller frames.
* Treat generator functions as normal functions when evaluating and specializing.
2022-01-20 11:46:39 +00:00
Mark Shannon
e028ae99ec
bpo-45923: Handle call events in bytecode (GH-30364)
...
* Add a RESUME instruction to handle "call" events.
2022-01-06 13:09:25 +00:00
penguin_wwy
3db762db72
bpo-46031: add POP_JUMP_IF_NOT_NONE and POP_JUMP_IF_NONE (GH-30019)
2022-01-06 11:38:35 +00:00
Brandt Bucher
31e43cbe5f
bpo-46009: Remove GEN_START (GH-30367)
2022-01-04 11:38:32 -08:00
Irit Katriel
a94461d718
bpo-46202: Remove opcode POP_EXCEPT_AND_RERAISE (GH-30302)
...
* bpo-46202: remove opcode POP_EXCEPT_AND_RERAISE
* do not assume that an exception group is truthy
2022-01-04 10:37:12 +00:00
Irit Katriel
65e7c1f90e
bpo-46219, 46221: simplify except* implementation following exc_info changes. Move helpers to exceptions.c. Do not assume that exception groups are truthy. (GH-30289)
2022-01-02 23:22:42 +00:00
Jason R. Coombs
e712a5b277
bpo-46118: Move importlib.resources to its own package. ( #30176 )
...
* bpo-46118: Move importlib.resources to its own package.
* Expand compatibility shims with documentation and explicit imports.
2021-12-30 21:00:48 -05:00
Jason R. Coombs
9b52920173
bpo-46125: Refactor tests to test traversable API directly. Includes changes from importlib_resources 5.4.0. (GH-30189)
2021-12-18 21:28:49 -05:00
Irit Katriel
396b58345f
bpo-45711: Remove type and traceback from exc_info (GH-30122)
...
* Do not PUSH/POP traceback or type to the stack as part of exc_info
* Remove exc_traceback and exc_type from _PyErr_StackItem
* Add to what's new, because this change breaks things like Cython
2021-12-17 14:46:22 +00:00
Jason R. Coombs
04deaee4c8
bpo-44893: Implement EntryPoint as simple class with attributes. (GH-30150)
...
* bpo-44893: Implement EntryPoint as simple class and deprecate tuple access in favor of attribute access. Syncs with importlib_metadata 4.8.1.
* Apply refactorings found in importlib_metadata 4.8.2.
2021-12-16 15:49:42 -05:00
Jason R. Coombs
109d966021
bpo-46105: Honor spec when generating requirement specs with urls and extras. (GH-30151)
2021-12-16 15:48:35 -05:00
Mark Shannon
0b50a4f0cd
bpo-46039: Split yield from in two (GH-30035)
...
* Split YIELD_FROM opcode into SEND and JUMP_ABSOLUTE.
* Remove YIELD_FROM opcode.
2021-12-15 10:30:09 +00:00
Mark Shannon
9f8f45144b
bpo-44525: Split calls into PRECALL and CALL (GH-30011)
...
* Add 3 new opcodes for calls: PRECALL_METHOD, CALL_NO_KW, CALL_KW.
* Update specialization to handle new CALL opcodes.
* Specialize call to method descriptors.
* Remove old CALL opcodes: CALL_FUNCTION, CALL_METHOD, CALL_METHOD_KW, CALL_FUNCTION_KW.
2021-12-14 18:22:44 +00:00
Irit Katriel
d60457a667
bpo-45292: [PEP-654] add except* (GH-29581)
2021-12-14 16:48:15 +00:00
Jason R. Coombs
d5cd2effa6
bpo-45514: Deprecate importlib resources legacy functions. (GH-29036)
...
* bpo-45514: Apply changes from importlib_resources@a3ef4128c6
* Mark legacy functions as deprecated in the docs and link to the migration docs in importlib_resources docs.
* Apply changes from importlib_resources@329ae9d5f2c.
* Indicate importlib.resources as a module.
Co-authored-by: Filipe Laíns <lains@riseup.net>
2021-11-24 02:51:37 -05:00
Miro Hrončok
ae1965ccb4
bpo-45703: Invalidate _NamespacePath cache on importlib.invalidate_ca… (GH-29384)
...
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.
2021-11-23 07:38:02 -08:00