[Import-SIG] DeprecationWarning for Python3.6 - Loaders create_module()

Brett Cannon brett at python.org
Tue Nov 17 12:41:02 EST 2015


On Tue, 17 Nov 2015 at 02:30 Raúl Cumplido <raulcumplido at gmail.com> wrote:

> Hi all,
>
> I am preparing a talk for PyCon ES (Spanish PyCon) about the import
> machinery and I was taking a look on the
> importlib/_bootstrap.py#module_from_spec
>
> I see there is a Deprecation warning as on Python3.6 loaders defining exec
> module must also define create module, but there is also a comment that
> says: "Typically loaders will not implement create_module()"
>
> I see that a little bit contradictory,
>

So it's not contradictory if you happen to realize the implicit ending to
that comment is "... because importlib.abc.Loader defines the method."


> what are the expected changes for the new Python3.6 version?
>

Loaders must implement create_module() if they define exec_module().


> Are the existing Loaders going to be changed to implement create_module?
>

They all have since Python 3.5; remember that create_module() can return
None and that will follow default semantics, so defining the method can be
as short as `def create_module(self): pass`.


>
> Sorry if this has been explained before but I cannot find in the archives
> the rationale for that.
>

https://bugs.python.org/issue23014

-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20151117/02b6e409/attachment.html>


More information about the Import-SIG mailing list