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

2011-08-07 Thread Ryan Kelly
On Sun, 2011-08-07 at 11:11 -0700, Josh Haberman wrote: > 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 inter

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

2011-08-07 Thread Steven D'Aprano
Josh Haberman wrote: > 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 > probabl

Re: import hooks

2008-04-18 Thread gagsl-py2
--- Patrick Stinson <[EMAIL PROTECTED]> escribió: > Right on, that seemed to work, thanks. > This is different than sys.path_hooks though, which > requires a callable or > string subclass? Yes, it's different, meta_path is a generic mechanism that doesn't depend on sys.path and is tried before sy

Re: import hooks

2008-04-17 Thread Patrick Stinson
Right on, that seemed to work, thanks. This is different than sys.path_hooks though, which requires a callable or string subclass? After some experimentation it looks like you can disallow an import by raising an import error from your meta_path hook. It seems a little weird that python will then

Re: import hooks

2008-04-16 Thread Gabriel Genellina
En Wed, 16 Apr 2008 09:04:36 -0300, Patrick Stinson <[EMAIL PROTECTED]> escribió: > I am defining a simple finder/loader object and adding it to > sys.meta_path > like this: > > PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = > [ousiainternal.OusiaImporter]"); You should

Re: import hooks

2008-04-16 Thread Patrick Stinson
I am defining a simple finder/loader object and adding it to sys.meta_path like this: PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = [ousiainternal.OusiaImporter]"); The following C code defines the loader object: static void MyImporter_dealloc(PyObject *self) { self-

Re: import hooks

2008-04-15 Thread Gabriel Genellina
En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson <[EMAIL PROTECTED]> escribió: > What's the current way to install an import hook? I've got an embedded > app > that has a few scripts that I want to import each other, but that are > not in > sys.modules. I intentionally keep them out of sy