Re: Round 2 for "A ModuleSpec Type for the Import System"

Eric Snow <[email protected]>
Newsgroups gmane.comp.python.import
Message-ID <CALFfu7Dg7T5WcknM3kxzqinNm_8r8opLo-MVbVxTx4L3xxK-zg@mail.gmail.com>
On Aug 28, 2013 11:27 AM, "Brett Cannon" <[email protected]> wrote:
> On Wed, Aug 28, 2013 at 12:04 PM, Eric Snow <[email protected]>
wrote:
>>
>> On Wed, Aug 28, 2013 at 8:43 AM, Eric Snow <[email protected]>
wrote:
>>>
>>> On Aug 28, 2013 3:26 AM, "Nick Coghlan" <[email protected]> wrote:
>>> > I realised that if we're going to allow mutating the spec in create,
we're going to have to promise not to reuse them across load calls. So
loaders can be shared, but specs can't.
>>>
>>> The latest version of the PEP already specifies that each module will
have its own copy, even if the spec is otherwise the same.  Perhaps it
should also make clear that loading_info should not be shared between
specs.  It wouldn't hurt to also say something about allowing only one call
to load() or something along those lines
>>
>> I see three options:
>>
>> 1. We advise against calling Modulespec.create() and ModuleSpec.load()
more than once.
>> 2. ModuleSpec's create() and load() programmatically disallow (or
otherwise handle) being called more than once.
>> 3. Dictate that Loader.create_module() must handle the case where it is
called more than once.  Fail?  Return None?  Return the same module as
before?
>>
>> I'll advocate for 3 along with making sure ModuleSpec.create() correctly
handles the exceptional response of Loader.create_module().  However, the
PEP does not really specify what happens when create() and load() are
called multiple times.  That needs to be added.  I'm tempted to have load()
simply return whatever is in sys.modules and bypass loading if the module
is already loaded.
>
>
> Isn't that the point of reload() sans the blind return? This is heading
down the road of trying to worry about stuff that will likely never happen
except by people trying to bypass the import system and thus are just
asking to get screwed up. We shouldn't bend over to block or (or support
it).

I'm fine with that.  My only concern is the case where people take
advantage of the spec methods to directly load/reload/etc. and it behaves
in an unexpected way.

-eric

_______________________________________________
Import-SIG mailing list
[email protected]
http://mail.python.org/mailman/listinfo/import-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.