New submission from Oren Milman:

the proposed changes:
1. it seems there is some mix-up with the terms 'importer' and 'finder' (and 
rarely also 'loader') in the import system and in related code (I guess most of 
it is just relics from the time before PEP 302).
The rational is simply https://docs.python.org/3/glossary.html#term-importer, 
which means (as I understand it) that the only place where 'importer' is 
appropriate is where the described object is guaranteed to be both a finder and 
loader object (i.e. currently only any of the following: BuiltinImporter, 
FrozenImporter, ZipImporter, mock_modules, mock_spec, TestingImporter).

Note: At first I pondered about also changing local variable names and even the 
name of a static C function, so I posted a question to the core-mentorship 
mailing list, and ultimately accepted (of course) the answer - 
https://mail.python.org/mailman/private/core-mentorship/2016-April/003541.html 
- fix only docs.

these proposed changes are in the following files:
    - Python/import.c (also changed the line saying that get_path_importer 
returning None tells the caller it should fall back to the built-in import 
mechanism, as it is no longer true, according to 
https://docs.python.org/3/reference/import.html#path-entry-finders. As I 
understand it, the last is indeed the right one)
    - Doc/c-api/import.rst (also changed the parallel doc of the aforementioned 
comment in Python/import.c)
    - Lib/pkgutil.py
    - Doc/Library/pkgutil.rst
    - Lib/runpy.py (also changed the function comment of _get_module_details, 
which specified wrong return values)
    - Lib/test/test_pkgutil.py
    

2. While scanning every CPython file that contains the string 'importer', 
Anaconda (a Sublime Package for Python) found two local variable assignments 
which were never used. I commented both out (and added a comment stating why). 
I would be happy to change those two tiny fixes if needed. 

these proposed changes are in the following files:
    - Lib/test/test_importlib/import_/test_meta_path.py
    - Lib/test/test_importlib/util.py


diff:
The patches diff is attached.


tests:
I built the changed *.rst files, and they looked fine.

I played a little with the interpreter, and everything worked as usual.
In addition, I run 'python -m test' (on my 64-bit Windows 10) before and after 
applying the patch, and got quite the same output.
the outputs of both runs are attached.

----------
components: Library (Lib)
files: issue.diff
keywords: patch
messages: 264576
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: mix-up with the terms 'importer', 'finder', 'loader' in the import 
system and related code
versions: Python 3.6
Added file: http://bugs.python.org/file42666/issue.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26896>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to