Ticket #3419 defect closed fixed
twisted.python.modules.walkModules fails completely if there is an unimportable package anywhere in the path
| Reported by: | exarkun | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | core | Keywords: | |
| Cc: | jessica.mckellar@…, thijs | Branch: | branches/walkModulesNone-3419 |
| Author: | glyph | Launchpad Bug: |
Description
exarkun@boson:/tmp/modules$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import modules
>>> modules['OpenSSL'] = None
>>> from twisted.python.modules import walkModules
>>> list(walkModules())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/exarkun/Projects/Twisted/trunk/twisted/python/modules.py", line 715, in walkModules
for module in package.walkModules(importPackages=False):
File "/home/exarkun/Projects/Twisted/trunk/twisted/python/modules.py", line 175, in walkModules
for package in self.iterModules():
File "/home/exarkun/Projects/Twisted/trunk/twisted/python/modules.py", line 127, in iterModules
for placeToLook in self._packagePaths():
File "/home/exarkun/Projects/Twisted/trunk/twisted/python/modules.py", line 420, in _packagePaths
load = self.load()
File "/home/exarkun/Projects/Twisted/trunk/twisted/python/modules.py", line 380, in load
return self.pathEntry.pythonPath.moduleLoader(self.name)
File "/home/exarkun/Projects/Twisted/trunk/twisted/python/reflect.py", line 460, in namedAny
raise ModuleNotFound("No module named %r" % (name,))
twisted.python.reflect.ModuleNotFound: No module named 'OpenSSL'
>>>
Specifically, this makes the unit test for walkModules rather fragile. In trying to resolve #3111, it is not clear how to make this test pass.
Generally, it's kind of crummy for any one bad module in the path to completely disable this API.
Also, it's kind of crummy that the twisted.python.modules tests load such a huge quantity of Python code, since this makes them rather slow.
Change History
Note: See
TracTickets for help on using
tickets.
