Message294919
Encountered this issue porting Python 2 code manipulating meta_path to Python 3.
In Python 2, meta_path is empty by default and its documentation specifically notes that:
> sys.meta_path is searched before any implicit default finders or sys.path.
As a result, sys.meta_path.append() works perfectly well and is overwhelmingly common[0].
In Python 3, this note was removed but the documentation does not specifically state default finders are present in meta_path, and the old code using sys.meta_path.append may now break as the default finders will silently take precedence on the custom ones if they believe they can do the job.
I'd like to add a warning to the Python 3 documentation (3.5+?) noting the presence of existing default loaders, and to the Python 2 documentation suggesting `sys.meta_path.insert(0, finder)` for future-proofing, would there be objections or issues?
[0] https://github.com/search?q=meta_path.append&type=Code&utf8=✓ |
|
| Date |
User |
Action |
Args |
| 2017-06-01 08:59:10 | xmorel | set | recipients:
+ xmorel, docs@python |
| 2017-06-01 08:59:10 | xmorel | set | messageid: <[email protected]> |
| 2017-06-01 08:59:10 | xmorel | link | issue30535 messages |
| 2017-06-01 08:59:10 | xmorel | create | |
|