Opened 12 years ago

Closed 12 years ago

#2037 defect closed duplicate (duplicate)

twisted.python.reflect.namedAny depends on undocumented import implementation details

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


In attempting to detect ImportErrors which result from exceptions rather than missing modules, namedAny relies on the fact that CPython's import only uses a single frame for its import logic. If this changes, or if an alternate runtime (for example, PyPy) is used, ImportErrors which stem from the lookup of a module which really does not exist will be re-raised incorrectly.

For example:

Traceback (most recent call last):
  File "", line 4, in <module>
  File "/Users/stephen/pypy-packages/twisted/scripts/", line 339, in run
    config = Options()
  File "/Users/stephen/pypy-packages/twisted/scripts/", line 129, in __init__
  File "/Users/stephen/pypy-packages/twisted/scripts/", line 138, in _loadReporters
    for p in plugin.getPlugins(itrial.IReporter):
--- <exception caught here> ---
  File "/Users/stephen/pypy-packages/twisted/", line 219, in getPlugins
    adapted = interface(plugin, None)
  File "zope/interface/", line 679, in __call__
    adapter = conform(self)
  File "/Users/stephen/pypy-packages/twisted/", line 77, in __conform__
    return self.load()
  File "/Users/stephen/pypy-packages/twisted/", line 72, in load
    return namedAny(self.dropin.moduleName + '.' +
  File "/Users/stephen/src/Twisted/trunk/twisted/python/", line 352, in namedAny
    topLevelPackage = __import__(trialname)
  File "/Users/stephen/src/pypy-fresh/pypy/lib/", line 208, in __lockedimport__
    return _original_import_hook(modulename, globals, locals, fromlist)
exceptions.ImportError: No module named twisted.plugins.twisted_trial.BlackAndWhite

Change History (4)

comment:1 Changed 12 years ago by jknight

Suggested fix? Look at the actual error message in the exception?

comment:2 Changed 12 years ago by Jean-Paul Calderone

I don't have a better idea yet. Looking at the message is pretty icky, though :(

comment:3 Changed 12 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

I suppose this is a duplicate of #698.

comment:4 Changed 8 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.