[Python-ideas] Implicit submodule imports

Brett Cannon brett at python.org
Mon Sep 29 16:07:29 CEST 2014


On Sun Sep 28 2014 at 1:56:35 PM Terry Reedy <tjreedy at udel.edu> wrote:

> On 9/28/2014 12:03 PM, Nathaniel Smith wrote:
> > On 28 Sep 2014 15:09, "Brett Cannon"
> > <brett at python.org
> > <mailto:brett at python.org>> wrote:
> >  >
> >  > On Sat Sep 27 2014 at 11:37:16 AM Nathaniel Smith
> > <njs at pobox.com
> > <mailto:njs at pobox.com>> wrote:
> >  >>
> >  >> On Sat, Sep 27, 2014 at 1:33 AM, Steven D'Aprano
> > <steve at pearwood.info
> > <mailto:steve at pearwood.info>> wrote:
> >  >> > Or perhaps these special "modules" could subclass ModuleType and
> > somehow
> >  >> > get reloading to work correctly. In 2.7 at least you can manually
> > copy a
> >  >> > module to a module subclass, install it into sys.modules, and
> reload
> >  >> > will accept it. Not only that, but after reloading it still uses
> the
> >  >> > same subclass.
> >  >> >
> >  >> > Unfortunately, when I tried it in 3.3, imp.reload complained about
> my
> >  >> > custom module subclass not being a module, so it seems that 3.3 at
> > least
> >  >> > is more restrictive than 2.7. (Perhaps 3.3 reload does a
> "type(obj) is
> >  >> > ModuleType" instead of isinstance test?)
> >  >>
> >  >> Yeah, it looks like 3.3 does an explicit 'type(obj) is ModuleType'
> >  >> check, but is the only version that works like this -- earlier and
> >  >> later versions both use isinstance.
> >  >
> >  >
> >  > Feel free to file an issue about this.
> >
> > I thought 3.3 is in security-fix only mode?
>
> It is.
>

Sorry, my brain read that as "since 3.3", not as "in 3.3" and missed the
"later versions" bit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140929/72462eb9/attachment.html>


More information about the Python-ideas mailing list