Brett Cannon added the comment:

What do you think about requiring create_module() and/or not supporting a None 
value return? The only reason I ask is to think through the ramifications and 
how long to raise a DeprecationWarning. I think I can live with having a 
reasonable default if create_module() isn't defined, but also supporting None 
seems a bit much. Or I can live with a None value to have import just do the 
most reasonable thing, but you should then explicitly ask for that by returning 
None. Or we just go full-on explicit and require create_module() and that it 
return the object to use.

So assuming we go with the latter, that means people who chose to not subclass 
importlib.abc.Loader will have to now implement create_module(). In Python 3.5 
that's easy since importlib.util.module_from_spec() now exists. But if you're 
supporting older versions it's a bit more work since there was only 
types.ModuleType() and that didn't fill in all attributes since it was missing 
key bits of information that is now (potentially) in the spec. That means if 
someone wants to be compatible from 3.4 on then it will be a bit of work to do 
properly.

That means either a deprecation cycle that is long enough to outlast code that 
wants to work in 3.4 or we don't go as far and support either returning None 
*or* not defining create_module(). My gut says to either deprecate both options 
and make the deprecation last until Python 4 or to require create_module() but 
allow for the returning of None and have that last only a single release since 
adding a create_module() that returns None takes no effort and is fully 
backwards-compatible (my reasoning for the latter is that screwing up to return 
None when you meant a module is easier to debug than accidentally typing the 
method name, plus it means people calling super() won't break in a transition).

----------

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

Reply via email to