durusmail: quixote-users: RELEASED: Quixote 2.7b1
RELEASED: Quixote 2.7b1
2009-10-21
RELEASED: Quixote 2.7b1
Benjamin Dauvergne
2010-01-21
Robert Ladyman wrote:
> Thanks for that - I never managed to fix it, but as I only used PTL in one
> place, I got rid of it and then did not enable PTL which at least bypassed the
> problem.
>
> RJL
>
>
>
>> On Wed, Oct 21, 2009 at 3:46 AM, Robert Ladyman  wrote:
>>
>>> Futher to my own post, the error is triggered with the FAVICON...decode()
>>> call in
>>>
>>> site-packages/quixote/demo/root.ptl
>>>
>>> and actually caused by
>>>
>>> python2.6/encodings/__init__.py (line 100) (forcing the error, I think).
>>>
>> I don't really get what is going on here, but I have the same issues.
>> It's more than just encodings, anything which uses import hooks seems
>> to hit this.
>>
>> A total hack which does work around this is changing ptl_import.py:133 to
>>  be: --
>>         def import_wrapper(name, globals={}, locals={}, fromlist=[],
>>  level=-1): return cimport.import_module(name, globals, locals, fromlist)
>>  __builtin__.__import__ = import_wrapper
>> --
>> but I don't know the negative impact (esp. of dropping the level
>> argument). Presumably the cimport.import_module should just implement
>> the expected interface, but I wasn't up for a real patch. :)
We have this problem in w.c.s (http://wcs.entrouvert.org), I use this
version of your work around, just after calling enable_ptl():

-=-=-=-=-=-=-
enable_ptl()

import sys
# Make ihooks works under python-2.6, problem is that ihooks is broken AND
# deprecated, and so will be removed in python-3.0 without being repaired
# before and there no transition module.
# The exact problem is that the ihooks __import__ implementation does not
# handle the last argument 'level', which is used to do 'relatives' import
if sys.version_info >= (2, 6):
    import __builtin__
    import ihooks
    __old_importer = __builtin__.__import__
    __very_old_importer = ihooks.current_importer.save_import_module
    def __import_wrapper(name, globals={}, locals={}, fromlist=[],
level=-1):
        if level == -1:
            return __old_importer(name, globals, locals, fromlist)
        else:
            return __very_old_importer(name, globals, locals, fromlist,
level)
    __builtin__.__import__ = __import_wrapper
-=-=-=-=-=-=-
reply