Re: Round 2 for "A ModuleSpec Type for the Import System"
Brett Cannon <[email protected]>
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CAP1=2W6oOgpWD74R9OHNHxVvQhUkF06vWzQNw+KUJSwYxNSD-Q@mail.gmail.com> |
On Tue, Aug 13, 2013 at 12:17 AM, Eric Snow <[email protected]>wrote: > On Sun, Aug 11, 2013 at 2:08 PM, Brett Cannon <[email protected]> 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? _______________________________________________ Import-SIG mailing list [email protected] http://mail.python.org/mailman/listinfo/import-sig