[PyQt] Eric3 issue: importing modules with the same name as an Eric module
Sundance
sundance at ierne.eu.org
Tue Oct 9 18:34:55 BST 2007
Sundance wrote:
> As time allows, yes, with pleasure. No promise about how successful
> it's gonna be, though, seeing as we're talking badass advanced snake
> charming here; we'll see how that goes.
... Ooooookay.
This was even worse than I imagined, but I'm done and, crazily enough,
it seems to work.
Here's how it works.
1) Drop the attached source file in the debugger's directory;
2) Surround the imports to be quarantined with the code that loads and
turns the quarantined import on, then off. For instance:
---[ Unquarantined imports ]-------------------------------------------
import A
import B
from C import D
-----------------------------------------------------------------------
... becomes...
---[ Quarantined imports ]---------------------------------------------
from QuarantinedImport import quarantined_import
quarantined_import.on()
import A
import B
from C import D
quarantined_import.off()
-----------------------------------------------------------------------
In Eric's case, that would make it:
---[ DebugClientBase.py excerpt ]--------------------------------------
[...]
from QuarantinedImport import quarantined_import
quarantined_import.on()
from DebugProtocol import *
import DebugClientCapabilities
from DebugBase import printerr
from AsyncFile import *
from Config import ConfigVarTypeStrings
from FlexCompleter import Completer
quarantined_import.off()
[...]
-----------------------------------------------------------------------
And yeah, that's it.
Warning: this tool is pure evil, it comes with no warranty whatsoever
and may eat kittens and/or puppies. Also, if there's a module that does
some very important things at load time that must only happen once, all
hell will likely break loose if you import that module both inside and
outside the quarantined zone. Consider yourself warned.
Feedback very welcome!
-- S.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QuarantinedImport.py
Type: application/x-python
Size: 4404 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20071009/cd2ec658/QuarantinedImport.bin
More information about the PyQt
mailing list