[issue18864] Implementation for PEP 451 (importlib.machinery.ModuleSpec)

Eric Snow report at bugs.python.org
Mon Nov 11 23:40:32 CET 2013


Eric Snow added the comment:

Sorry that wasn't more clear.  I committed the changes from the modulespec-primary-changes.diff patch to the pep451 branch in the server-side clone.  Those changes are:

Step 1
------
1. added ModuleSpec class
2. added _SpecMethods wrapper class
3. added ModuleSpec factory functions
4. added tests for ModuleSpec, _SpecMethods, and the factories
5. exposed ModuleSpec in importlib.machinery
6. exposed ModuleSpec factories in importlib.util
7. added basic docs for ModuleSpec and the factory functions

Step 2
------
1. changed _find_module() to _find_spec()
2. changed _find_and_load_unlocked() to use _find_spec() and _SpecMethods
3. changed _setup() to use specs
4. changed pydoc to recognize __spec__

Step 3
------
1. updated the import reference doc
2. changed importlib.reload() to use specs
3. added importlib.find_spec()
4. changed importlib.find_loader() to wrap find_spec()
5. updated importlib.abc to reflect the new APIs
6. changed pkgutil to use specs
7. changed imp to use specs
8. fixed a bunch of broken tests to use spec

Step 3
------
1. implemented find_spec() on PathFinder
2. implemented find_spec() on FileFinder
3. re-implemented FileFinder.find_loader() to wrap find_spec()
4. re-implemented PathFinder.find_module() to wrap find_spec()
5. changed _NamespacePath to use specs

Step 5
------
1. added _module_repr function
2. changed ModuleType.__repr__ to wrap _module_repr

Others
------
* removed _NamespaceLoader
* added comments indicating deprecations and removals

At this point, the test suite passes and the fundamental changes of the PEP are implemented (on the server-side clone).  Here's what's left to do before the feature freeze:

1. 
2. change module.__initializing__ to module.__spec__._initializing
3. refactor importlib loaders to use the new Finder/Loader APIs
4. refactor pythonrun.c to make use of specs
5. check pkgutil for any missed changes
6. implement the deprecations and removals
7. adjust other APIs to use __spec__ (pickle, runpy, inspect, pydoc, others?)
8. evaluate any impact on setuptools

Other things that can (but don't have to) wait until after the beta release:

* finish doc changes
* fill in any gaps in test coverage
* ensure new docstrings exist and are correct
* ensure existing docstrings are still correct

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18864>
_______________________________________


More information about the Python-bugs-list mailing list