From: Greg W. <gw...@me...> - 2002-02-28 19:58:35
|
On 28 February 2002, Neal Norwitz said: > I did mean that. If pychecker is imported, it installs an __import__ > hook, so any new modules being imported will be checked. > But I screwed up the order. It would have to import pychecker.checker > first, then ZODB. Ahh, import-time side effects. IMHO it would be much nicer to provide a function, eg. 'install_import_magic()', that people who want your import magic can call. The rest of us can then avoid having Python's behaviour implicitly changed on us. Anyways, here's what happens when I import pychecker before ZODB (this is with all my PyChecker patches applied, most importantly the importError() rewrite): >>> import pychecker.checker >>> import ZODB Caught exception importing module ExtensionClass: File "/home/gward/lib/python/pychecker/checker.py", line 445, in load() return self.initModule(module) File "/home/gward/lib/python/pychecker/checker.py", line 473, in initModule() self.addClass(tokenName, token) File "/home/gward/lib/python/pychecker/checker.py", line 411, in addClass() c.ignoreAttrs = packages[0] in cfg().blacklist File "/home/gward/lib/python/pychecker/checker.py", line 64, in cfg() return utils.cfg() File "/home/gward/lib/python/pychecker/utils.py", line 30, in cfg() return _cfg[-1] IndexError: list index out of range Unable to load module ExtensionClass Caught exception importing module ZODB.TimeStamp: File "/home/gward/lib/python/pychecker/checker.py", line 445, in load() return self.initModule(module) File "/home/gward/lib/python/pychecker/checker.py", line 473, in initModule() self.addClass(tokenName, token) File "/home/gward/lib/python/pychecker/checker.py", line 411, in addClass() c.ignoreAttrs = packages[0] in cfg().blacklist File "/home/gward/lib/python/pychecker/checker.py", line 64, in cfg() return utils.cfg() File "/home/gward/lib/python/pychecker/utils.py", line 30, in cfg() return _cfg[-1] IndexError: list index out of range Unable to load module ZODB.TimeStamp Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/gward/lib/python/pychecker/checker.py", line 618, in __import__ pymodule = _orig__import__(name, globals, locals, fromlist) File "lib.linux-i686-2.2/ZODB/__init__.py", line 13, in ? File "/home/gward/lib/python/pychecker/checker.py", line 618, in __import__ pymodule = _orig__import__(name, globals, locals, fromlist) File "/home/gward/lib/python/pychecker/checker.py", line 618, in __import__ pymodule = _orig__import__(name, globals, locals, fromlist) ImportError: No module named TimeStamp >>> Note that the first two tracebacks come from my rewrite of importError(); the last one appears to be a genuine Python traceback. > Yes, there were a few hacks (which you've already seen :-) to try > to deal with this (xml does some similar tricks, but probably not as > bad). ZODB is waaaaay too tricky for my taste. I hope PyChecker isn't as evil, but I'm starting to have a bad feeling. I'm thinking of ripping all the import-time magic out of one or both of them to see what happens. > I'll try to get your patches integrated soon, and perhaps we can > start cleaning up the code. Great -- good to know I'm not just talking to myself when I upload those patches. ;-) Greg -- Greg Ward - software developer gw...@me... MEMS Exchange http://www.mems-exchange.org |