durusmail: quixote-users: ihooks module broken in Python 2.6
ihooks module broken in Python 2.6
2008-10-21
ihooks module broken in Python 2.6
Neil Schemenauer
2008-10-20
I just noticed that the ihooks module in Python 2.6 does not support
absolute imports.  That's bad since the stdlib "encodings" module
uses one.  Since ihooks is going away in 3.x anyhow, I was thinking
the best solution would be to allow PTL code to be compiled similar
to QPY.  My implementation is pretty similar; the following code
would be added to a __init__.py file for a package containing PTL:

    from quixote.ptl import compile_package
    compile_package(__file__)

The compile_package() function uses os.walk to recursively find and
compile all .ptl files in the package.  Some possible problems:

    * Modules are compiled even if they are not actually used.  That
      could be annoying if you are part way implementing something.

    * reload() won't work

    * The code does not check .pyc magic.  If you upgrade Python
      then you might have to remove incompatible .pyc files.  This
      could be fixed but performance would suffer a little.

How has the QPY scheme worked out in practice?  I think it has the
same issues.  I guess an alternative solution would be to roll my
own ihooks like functionally (yuck).

  Neil
reply