<p dir="ltr"><br>
On 31 Oct 2013 08:54, "Eric Snow" <<a href="mailto:ericsnowcurrently@gmail.com">ericsnowcurrently@gmail.com</a>> wrote:<br>
><br>
> On Wed, Oct 30, 2013 at 4:09 PM, Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
> > On 31 Oct 2013 03:41, "Eric Snow" <<a href="mailto:ericsnowcurrently@gmail.com">ericsnowcurrently@gmail.com</a>> wrote:<br>
> >> Our recent discovery about reloading should probably be reflected in<br>
> >> the signature of finder.find_spec():<br>
> >><br>
> >>   MetaPathFinder.find_spec(name, path=None, existing=None)<br>
> >>   PathEntryFinder.find_spec(name, existing=None)<br>
> >><br>
> >> This way the finder has an opportunity to incorporate information from<br>
> >> an existing spec into the spec it returns.  reload() would make use of<br>
> >> this by passing module.__spec__ (or None if the module has no<br>
> >> __spec__) to _bootstrap._find_spec().<br>
> >><br>
> >> This approach should also address what you are looking for.  I'd<br>
> >> prefer it over passing the existing spec to exec_module().  The module<br>
> >> (and its __spec__) should have everything exec_module() needs to do<br>
> >> its job.<br>
> ><br>
> > Yes, that should work.<br>
><br>
> Cool.  I'll update the PEP.<br>
><br>
> ><br>
> >> We would still need to use loader.supports_reload() in reload().<br>
> ><br>
> > Why? If the reload isn't supported, exec_module can just throw an exception<br>
> > based on the loader state in the spec.<br>
><br>
> At the point that exec_module() gets called, the loader can't check<br>
> sys.modules to see if it's a reload or not.  As a workaround, the<br>
> finder could set up some loader state to indicate to the loader that<br>
> it's a reload and then the loader, during exec_module(), would check<br>
> that and act accordingly.  However, that's the sort of boilerplate<br>
> that PEP 451 is trying to offload onto the import machinery.  With<br>
> Loader.supports_reload() it's a lot cleaner.</p>
<p dir="ltr">There's also the option of implementing the constraint directly in the finder, which *does* have the necessary info (with the change to pass the previous spec to find_spec).</p>
<p dir="ltr">I still think it makes more sense to leave this out for the moment - it's not at all clear we need the extra method, and adding it later would be a straightforward protocol update.</p>
<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> -eric<br>
><br>
> ><br>
> > From the import system's point of view "reload not permitted" is no<br>
> > different from any other exec time failure.<br>
> ><br>
> > Cheers,<br>
> > Nick.<br>
</p>