[issue23014] Don't have importlib.abc.Loader.create_module() be optional

Brett Cannon report at bugs.python.org
Wed Jun 26 16:00:11 EDT 2019


Brett Cannon <brett at python.org> added the comment:

> Mostly looking for something that says how `create_module` should / shouldn't be implemented

Basically you only need to provide the method if you want to use a custom object for the module itself. So as long as the object can quack like a module object you should be fine.

> (and why `return None` is necessary)

The "return None for default semantics" is there for two reasons (if I remember correctly). One, it makes it very easy to implement the default semantics. :) Two, it sends a very clear signal that nothing out of the ordinary is going on and so you can assume nothing special is expected (which is why LazyLoader requires this since it mucks with the object directly in a very specific way).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue23014>
_______________________________________


More information about the Python-bugs-list mailing list