[Import-SIG] backport of importlib

Nick Coghlan ncoghlan at gmail.com
Sat Jul 16 10:22:39 CEST 2011

On Sat, Jul 16, 2011 at 5:42 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> So I've gone ahead and written a (naive and probably incomplete)
> script that backports importlib to 2.x[1].  There were a few syntax
> differences, a couple of modules were new or had new functions, and I
> had to reintroduce the old-style relative imports.

I suspect several of the transforms you're applying would be handled
natively by 3to2 - have you looked into using that at all?

> I'm hoping this will allow PEP 382 and the import engine to both be
> backported simply by running this script on the implementation out of
> 3.3.  This was definitely a good exercise in getting familiar with the
> importlib implementation.

Did I ever tell you about the (deliberately undocumented) standard
import emulation in pkgutil? That's what runpy and a couple of other
pieces of the 2.x stdlib use to get around the fact that importlib
didn't exist until recently (and still doesn't exist in its full form
in 2.x). (Although I guess relying on that would make it harder to use
importlib itself when forward porting to 3.x)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Import-SIG mailing list