Re: DeprecationWarning for Python3.6 - Loaders create_module()
Brett Cannon <[email protected]> Tue, 17 Nov 2015 17:41:02 +0000
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CAP1=2W5nT4khepQ0Bq7KiXH25x_rFkk8OYw6ngOwTqTbgQ=B=Q@mail.gmail.com> |
--===============0508053398337874645== Content-Type: multipart/alternative; boundary=001a114e72b22e11380524c0087b --001a114e72b22e11380524c0087b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 17 Nov 2015 at 02:30 Ra=C3=BAl Cumplido <[email protected]> wr= ote: > 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 exe= c > 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 --001a114e72b22e11380524c0087b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Tue= , 17 Nov 2015 at 02:30 Ra=C3=BAl Cumplido <<a href=3D"mailto:raulcumplid= [email protected]">[email protected]</a>> wrote:<br></div><blockquote cla= ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa= dding-left:1ex"><div dir=3D"ltr">Hi all,<div><br></div><div>I am preparing = a talk for PyCon ES (Spanish PyCon) about the import machinery and I was ta= king a look on the importlib/_bootstrap.py#module_from_spec</div><div><br><= /div><div>I see there is a Deprecation warning as on Python3.6 loaders defi= ning exec module must also define create module, but there is also a commen= t that says: "Typically loaders will not implement create_module()&quo= t;</div><div><br></div><div>I see that a little bit contradictory,</div></d= iv></blockquote><div><br></div><div>So it's not contradictory if you ha= ppen to realize the implicit ending to that comment is "... because im= portlib.abc.Loader defines the method."</div><div>=C2=A0</div><blockqu= ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s= olid;padding-left:1ex"><div dir=3D"ltr"><div> what are the expected changes= for the new Python3.6 version?</div></div></blockquote><div><br></div><div= >Loaders must implement create_module() if they define exec_module().</div>= <div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8= ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div> Are = the existing Loaders going to be changed to implement create_module?</div><= /div></blockquote><div><br></div><div>They all have since Python 3.5; remem= ber that create_module() can return None and that will follow default seman= tics, so defining the method can be as short as `def create_module(self): p= ass`.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"marg= in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"= ><div><br></div><div>Sorry if this has been explained before but I cannot f= ind in the archives the rationale for that.</div></div></blockquote><div><b= r></div><div><a href=3D"https://bugs.python.org/issue23014">https://bugs.py= thon.org/issue23014</a></div><div><br></div><div>-Brett=C2=A0</div></div></= div> --001a114e72b22e11380524c0087b-- --===============0508053398337874645== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Import-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/import-sig --===============0508053398337874645==--