[Import-SIG] Round 2 for "A ModuleSpec Type for the Import System"
Brett Cannon
brett at python.org
Tue Aug 13 15:21:42 CEST 2013
On Tue, Aug 13, 2013 at 12:17 AM, Eric Snow <ericsnowcurrently at gmail.com>wrote:
> On Sun, Aug 11, 2013 at 2:08 PM, Brett Cannon <brett at python.org> wrote:
>
>>
>>
[SNIP]
>
>>
>>> ``module_repr()`` also conflicts with the same
>>> method on loaders, but that workaround is not complicated since both are
>>> methods.
>>>
>>> Unfortunately, the ability to proxy does not extend to ``id()``
>>> comparisons and ``isinstance()`` tests. In the case of the return value
>>> of ``find_module()``, we accept that break in backward compatibility.
>>> However, we will mitigate the problem with ``isinstance()`` somewhat by
>>> registering ``ModuleSpec`` on the loaders in ``importlib.abc``.
>>>
>>
>> Actually, ModuleSpec doesn't even need to register; __instancecheck__ and
>> __subclasscheck__ can just be defined and delegate by calling
>> issubclass/isinstance on the loader as appropriate.
>>
>
> Do you mean add custom versions of those methods to importlib.abc.Loader?
>
Nope, I meant ModuleSpec because every time I have a reason to override
something it's on the object and not the class and so I forget the support
is the other way around. Argh.
> That should work as well as the register approach. It won't work for all
> loaders but should be good enough. I was just planning on registering
> ModuleSpec on the loader in the setter for a `loader` property on
> ModuleSpec.
>
But the registration is at the class level so how would that work?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20130813/228a9772/attachment.html>
More information about the Import-SIG
mailing list