twisted.trial.runner.filenameToModule should not swallow unrelated exceptions

[email protected] Wed, 25 Nov 2009 17:12:56 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from arkanes <[email protected]>:

When converting a filename to a module for running with trial, filenameToModule first tries reflect.namedAny, checks for ValueError or AttributeError, and then falls back to imp.load_source. This implicitly assumes that when an exception is raised when importing a module, importing it again (via imp) will either fail the same way or succeed normally (if the file was fixed in a race condition or something). In the specific case of extension modules, this is not true - they leave module objects in sys.modules if they raise an exception when imported.

This is a Python bug but the way trial does this import exacerbates the issue.

Helpfully, reflect.namedAny raises more specific exceptions that filenameToModule should catch instead.

----------
Type     : defect
Component: runner
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4134