Python Import Hooks and __main__

2015-08-17 Thread Sven R. Kunze
Hi, following up on this thread on StackOverflow http://stackoverflow.com/questions/16515347/python-import-hooks-and-main does somebody has a great idea how to manage this? The issue at hand is, that I would like to apply a specific import hook right from the beginning of the interpreter

Re: Question about import hooks

2013-11-23 Thread Mark Lawrence
On 23/11/2013 12:23, Ed Schofield wrote: Hi all, I am the author of the ``future`` package for Python 2/3 compatibility (http://python-future.org). A bug report has recently been posted about its use of import hooks that I don't yet have an answer for, and I am looking for some guidan

Question about import hooks

2013-11-23 Thread Ed Schofield
Hi all, I am the author of the ``future`` package for Python 2/3 compatibility (http://python-future.org). A bug report has recently been posted about its use of import hooks that I don't yet have an answer for, and I am looking for some guidance on how to customize the import mechanism

Dealing with ImportLock deadlock in Import Hooks

2013-08-02 Thread Arnaud Fontaine
Hello, I'm currently working on implementing Import Hooks (PEP302) with Python 2.7 to be able to import modules whose code is in ZODB. However, I have stumbled upon a widely known issue about import deadlock[0][1] (note that this issue is not directly related to ZODB, but a more general que

Dealing with ImportLock deadlock in Import Hooks

2013-08-02 Thread Arnaud Fontaine
Hello, I'm currently working on implementing Import Hooks (PEP302) with Python 2.7 to be able to import modules whose code is in ZODB. However, I have stumbled upon a widely known issue about import deadlock[0][1] (note that this issue is not directly related to ZODB, but a more general que

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 > s

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 inte

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

2011-08-07 Thread 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* avo

Re: Creating Import Hooks

2010-02-18 Thread Jonathan Gardner
On Feb 18, 1:28 am, Sreejith K wrote: > On Feb 18, 1:57 pm, Steven D'Aprano > > > > wrote: > > On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote: > > > On Feb 17, 10:48 pm, Sreejith K wrote: > > >> Hi everyone, > > > >&

Re: Creating Import Hooks

2010-02-18 Thread Jean-Michel Pichavant
ryone, I need to implement custom import hooks for an application (http://www.python.org/dev/peps/pep-0302/). I want to restrict an application to import certain modules (say socket module). Google app engine is using a module hook to do this (HardenedModulesHook in google/ appengine/

Re: Creating Import Hooks

2010-02-18 Thread Sreejith K
>>>> Hi everyone, > > >>>> I need to implement custom import hooks for an application > >>>> (http://www.python.org/dev/peps/pep-0302/). I want to restrict an > >>>> application to import certain modules (say socket module). Google app > &

Re: Creating Import Hooks

2010-02-18 Thread Jean-Michel Pichavant
Sreejith K wrote: On Feb 18, 1:57 pm, Steven D'Aprano wrote: On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote: On Feb 17, 10:48 pm, Sreejith K wrote: Hi everyone, I need to implement custom import hooks for an application (http://www.python.org/dev

Re: Creating Import Hooks

2010-02-18 Thread Sreejith K
On Feb 18, 1:57 pm, Steven D'Aprano wrote: > On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote: > > On Feb 17, 10:48 pm, Sreejith K wrote: > >> Hi everyone, > > >> I need to implement custom import hooks for an application > >> (http://w

Re: Creating Import Hooks

2010-02-18 Thread Steven D'Aprano
On Thu, 18 Feb 2010 00:03:51 -0800, Jonathan Gardner wrote: > On Feb 17, 10:48 pm, Sreejith K wrote: >> Hi everyone, >> >> I need to implement custom import hooks for an application >> (http://www.python.org/dev/peps/pep-0302/). I want to restrict an >> applicati

Re: Creating Import Hooks

2010-02-18 Thread Jonathan Gardner
On Feb 17, 10:48 pm, Sreejith K wrote: > Hi everyone, > > I need to implement custom import hooks for an application > (http://www.python.org/dev/peps/pep-0302/). I want to restrict an application > to import certain modules (say socket module). Google app engine is > using a

Creating Import Hooks

2010-02-17 Thread Sreejith K
Hi everyone, I need to implement custom import hooks for an application (http:// www.python.org/dev/peps/pep-0302/). I want to restrict an application to import certain modules (say socket module). Google app engine is using a module hook to do this (HardenedModulesHook in google/ appengine/tools

Problems with import hooks and encoding

2009-05-20 Thread Vinay Sajip
The simple program #-- def main(): print repr(u'\u2029'.encode('utf-8')) if __name__ == "__main__": main() #-- works as expected when run from the command-line, but fails when converted to an executable using PyI

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

import hooks

2008-04-15 Thread Patrick Stinson
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 sys.modules because their names will not be unique across the app. They will, however, be unique betw