def METHOD_NAME(main_module, old_modules):
  """Yields (module name, absolute path) pairs."""
  log('Importing %r', main_module)
  try:
    __import__(main_module)
  except ImportError, e:
    log('Error importing %r with sys.path %r', main_module, sys.path)
    # TODO: print better error.
    raise
  new_modules = sys.modules
  log('After importing: %d modules', len(new_modules))
  for name in sorted(new_modules):
    if name in old_modules:
      continue  # exclude old modules
    module = new_modules[name]
    full_path = getattr(module, '__file__', None)
    # For some reason, there are entries like:
    # 'pan.core.os': None in sys.modules.  Here's a hack to get rid of them.
    if module is None:
      continue
    # Not sure why, but some stdlib modules don't have a __file__ attribute,
    # e.g. "gc", "marshal", "thread".  Doesn't matter for our purposes.
    if full_path is None:
      continue
    yield name, full_path