code: def uninstall_bundle(self, bundle):
          # type: (Bundle) -> None
          
          if bundle is None:
              # Do nothing
              return
  
          with self.__bundles_lock:
              # Stop the bundle first
              bundle.stop()
  
              bundle_id = bundle.get_bundle_id()
              if bundle_id not in self.__bundles:
                  raise BundleException("Invalid bundle {0}".format(bundle))
  
              # Notify listeners
              self._dispatcher.fire_bundle_event(
                  BundleEvent(BundleEvent.UNINSTALLED, bundle)
              )
  
              # Remove it from the dictionary
              del self.__bundles[bundle_id]
  
              # Remove it from the system => avoid unintended behaviors and
              # forces a complete module reload if it is re-installed
              name = bundle.get_symbolic_name()
              try:
                  del sys.modules[name]
              except KeyError:
                  # Ignore
                  pass
  
              try:
                  # Clear reference in parent
                  parent, basename = name.rsplit(".", 1)
                  if parent:
                      delattr(sys.modules[parent], basename)
              except (KeyError, AttributeError, ValueError):
                  # Ignore errors
                  pass
docs: Ends the uninstallation of the given bundle (must be called by Bundle)
  
          :param bundle: The bundle to uninstall
          :raise BundleException: Invalid bundle