import hooks (PEP 302) broken in Python >=2.5?

J

Josh Haberman

When reading about import hooks, I came across a blog entry comment
that says:

One additional thing to note about ihooks is that it's
somewhat seriously broken on Python 2.5 and newer and there
seems to be little or no interest in fixing it. It's
probably worth *always* avoiding when writing new code.

--http://orestis.gr/blog/2008/12/20/python-import-hooks/#c264

Does anyone know what this is referring to? Should I be wary of
relying on import hooks?

Josh
 
S

Steven D'Aprano

Josh said:
When reading about import hooks, I came across a blog entry comment
that says:

One additional thing to note about ihooks is that it's
somewhat seriously broken on Python 2.5 and newer and there
seems to be little or no interest in fixing it. It's
probably worth *always* avoiding when writing new code.

--http://orestis.gr/blog/2008/12/20/python-import-hooks/#c264

Does anyone know what this is referring to? Should I be wary of
relying on import hooks?

Are you using import hooks? What version(s) of Python are you using?

Depending on whether you are asking out of curiosity, or because you have
code that uses import hooks and you're about to migrate from Python 2.3 to
3.1, the answers may be different.
 
R

Ryan Kelly

When reading about import hooks, I came across a blog entry comment
that says:

One additional thing to note about ihooks is that it's
somewhat seriously broken on Python 2.5 and newer and there
seems to be little or no interest in fixing it. It's
probably worth *always* avoiding when writing new code.

--http://orestis.gr/blog/2008/12/20/python-import-hooks/#c264

Does anyone know what this is referring to? Should I be wary of
relying on import hooks?

I believe that comment is referring specifically to "ihooks" the stdlib
module, not "import hooks" the general concept as defined in PEP302.
The former pre-dates the later.

I use custom PEP302 loaders all the time and they work fine in at least
2.6, 2.7 and 3.2.


Ryan

--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
(e-mail address removed) | http://www.rfk.id.au/ramblings/gpg/ for details


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEABECAAYFAk4/C6YACgkQfI5S64uP50riLQCfXGyux1ScyyfAqmbOdd9YnNkb
dp8AnRqZFEiRnctltboHCn0iEU2Yscys
=d6NS
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top