I traced it down to line 183 raising an exception. (ImportError, I believe...) But there wasn't anything useful
lines 181-193 look like:
for name in plugin_names:
try:
exec "import bzrlib.plugins.%s" % name in {}
except KeyboardInterrupt:
raise
except Exception, e:
## import pdb; pdb.set_trace()
if re.search('\.|-| ', name): warning('Unable to load plugin %r from %r: ' 'It is not a valid python module name.' % (name, d))
else: warning('Unable to load plugin %r from %r' % (name, d)) log_exception_quietly()
I can get the same error by adding a trailing slash to one of the entries in sys.path, and trying to load a file from that entry.
Z:\>dir c:\progra~1\Python\lib\bdb*
Volume in drive C has no label.
Volume Serial Number is 204B-2F2E
Z:\>python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\WINDOWS\\system32\\python25.zip', 'c:\\progra~1\\Python\\DLLs', 'c:\\p
rogra~1\\Python\\lib', 'c:\\progra~1\\Python\\lib\\plat-win', 'c:\\progra~1\\Pyt
hon\\lib\\lib-tk', 'c:\\progra~1\\Python', 'c:\\progra~1\\Python\\lib\\site-pack
ages', 'c:\\progra~1\\Python\\lib\\site-packages\\PIL', 'c:\\progra~1\\Python\\l
ib\\site-packages\\win32', 'c:\\progra~1\\Python\\lib\\site-packages\\win32\\lib
', 'c:\\progra~1\\Python\\lib\\site-packages\\Pythonwin']
>>> sys.path = ['', 'C:\\WINDOWS\\system32\\python25.zip', 'c:\\progra~1\\Python
\\DLLs', 'c:\\progra~1\\Python\\lib\\', 'c:\\progra~1\\Python\\lib\\plat-win', '
c:\\progra~1\\Python\\lib\\lib-tk', 'c:\\progra~1\\Python', 'c:\\progra~1\\Pytho
n\\lib\\site-packages', 'c:\\progra~1\\Python\\lib\\site-packages\\PIL', 'c:\\pr
ogra~1\\Python\\ib\\site-packages\\win32', 'c:\\progra~1\\Python\\lib\\site-pack
ages\\win32\\lib', 'c:\\progra~1\\Python\\lib\\site-packages\\Pythonwin']
>>> sys.path
['', 'C:\\WINDOWS\\system32\\python25.zip', 'c:\\progra~1\\Python\\DLLs', 'c:\\p
rogra~1\\Python\\lib\\', 'c:\\progra~1\\Python\\lib\\plat-win', 'c:\\progra~1\\P
ython\\lib\\lib-tk', 'c:\\progra~1\\Python', 'c:\\progra~1\\Python\\lib\\site-pa
ckages', 'c:\\progra~1\\Python\\lib\\site-packages\\PIL', 'c:\\progra~1\\Python\
\ib\\site-packages\\win32', 'c:\\progra~1\\Python\\lib\\site-packages\\win32\\li
b', 'c:\\progra~1\\Python\\lib\\site-packages\\Pythonwin']
>>> import bdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bdb
>>> import cgi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cgi
etc, etc...
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52662 suggests that you should call os.path.abspath and os.path.exists on the arguments before adding them to sys.path, which we oddly don't seem to do. (Oh, but we set the __path__ of the plugins module, which should do something similar.)
And in a tangent, we seem to set it twice in a row, once at line 92, and then again a few instructions later, at line 129. Should those both really be there?
I traced it down to line 183 raising an exception. (ImportError, I believe...) But there wasn't anything useful
lines 181-193 look like:
warning( 'Unable to load plugin %r from %r: '
' It is not a valid python module name.' % (name, d))
warning( 'Unable to load plugin %r from %r' % (name, d))
log_ exception_ quietly( )
for name in plugin_names:
try:
exec "import bzrlib.plugins.%s" % name in {}
except KeyboardInterrupt:
raise
except Exception, e:
## import pdb; pdb.set_trace()
if re.search('\.|-| ', name):
else:
I can get the same error by adding a trailing slash to one of the entries in sys.path, and trying to load a file from that entry.
Z:\>dir c:\progra~ 1\Python\ lib\bdb*
Volume in drive C has no label.
Volume Serial Number is 204B-2F2E
Directory of c:\progra~ 1\Python\ lib
12/05/2006 02:17 PM 20,756 bdb.py
11/07/2007 10:52 AM 18,353 bdb.pyc
11/07/2007 10:52 AM 18,353 bdb.pyo
3 File(s) 57,462 bytes
0 Dir(s) 126,196,838,400 bytes free
Z:\>python \system32\ \python25. zip', 'c:\\progra~ 1\\Python\ \DLLs', 'c:\\p \Python\ \lib', 'c:\\progra~ 1\\Python\ \lib\\plat- win', 'c:\\progra~1\\Pyt 1\\Python' , 'c:\\progra~ 1\\Python\ \lib\\site- pack 1\\Python\ \lib\\site- packages\ \PIL', 'c:\\progra~ 1\\Python\ \l packages\ \win32' , 'c:\\progra~ 1\\Python\ \lib\\site- packages\ \win32\ \lib 1\\Python\ \lib\\site- packages\ \Pythonwin' ] \system32\ \python25. zip', 'c:\\progra~ 1\\Python 1\\Python\ \lib\\' , 'c:\\progra~ 1\\Python\ \lib\\plat- win', ' 1\\Python\ \lib\\lib- tk', 'c:\\progra~ 1\\Python' , 'c:\\progra~ 1\\Pytho \site-packages' , 'c:\\progra~ 1\\Python\ \lib\\site- packages\ \PIL', 'c:\\pr \Python\ \ib\\site- packages\ \win32' , 'c:\\progra~ 1\\Python\ \lib\\site- pack 1\\Python\ \lib\\site- packages\ \Pythonwin' ] \system32\ \python25. zip', 'c:\\progra~ 1\\Python\ \DLLs', 'c:\\p \Python\ \lib\\' , 'c:\\progra~ 1\\Python\ \lib\\plat- win', 'c:\\progra~1\\P lib\\lib- tk', 'c:\\progra~ 1\\Python' , 'c:\\progra~ 1\\Python\ \lib\\site- pa 1\\Python\ \lib\\site- packages\ \PIL', 'c:\\progra~ 1\\Python\ packages\ \win32' , 'c:\\progra~ 1\\Python\ \lib\\site- packages\ \win32\ \li 1\\Python\ \lib\\site- packages\ \Pythonwin' ]
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\WINDOWS\
rogra~1\
hon\\lib\\lib-tk', 'c:\\progra~
ages', 'c:\\progra~
ib\\site-
', 'c:\\progra~
>>> sys.path = ['', 'C:\\WINDOWS\
\\DLLs', 'c:\\progra~
c:\\progra~
n\\lib\
ogra~1\
ages\\win32\\lib', 'c:\\progra~
>>> sys.path
['', 'C:\\WINDOWS\
rogra~1\
ython\\
ckages', 'c:\\progra~
\ib\\site-
b', 'c:\\progra~
>>> import bdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bdb
>>> import cgi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cgi
etc, etc...
http:// aspn.activestat e.com/ASPN/ Cookbook/ Python/ Recipe/ 52662 suggests that you should call os.path.abspath and os.path.exists on the arguments before adding them to sys.path, which we oddly don't seem to do. (Oh, but we set the __path__ of the plugins module, which should do something similar.)
And in a tangent, we seem to set it twice in a row, once at line 92, and then again a few instructions later, at line 129. Should those both really be there?