def readconfig(self, configpath=None):
        """
        :param configpath: Optional bugzillarc path to read, instead of
            the default list.

        This function is called automatically from Bugzilla connect(), which
        is called at __init__ if a URL is passed. Calling it manually is
        just for passing in a non-standard configpath.

        The locations for the bugzillarc file are preferred in this order:

            ~/.config/python-bugzilla/bugzillarc
            ~/.bugzillarc
            /etc/bugzillarc

        It has content like:
          [bugzilla.yoursite.com]
          user = username
          password = password
        Or
          [bugzilla.yoursite.com]
          api_key = key

        The file can have multiple sections for different bugzilla instances.
        A 'url' field in the [DEFAULT] section can be used to set a default
        URL for the bugzilla command line tool.

        Be sure to set appropriate permissions on bugzillarc if you choose to
        store your password in it!
        """
        cfg = _open_bugzillarc(configpath or self.configpath)
        if not cfg:
            return

        section = ""
        log.debug("bugzillarc: Searching for config section matching %s",
            self.url)

        def _parse_hostname(_u):
            # If http://example.com is passed, netloc=example.com path=""
            # If just example.com is passed, netloc="" path=example.com
            parsedbits = urlparse(self.url)
            return parsedbits.netloc or parsedbits.path

        urlhost = _parse_hostname(self.url)
        for sectionhost in sorted(cfg.sections()):
            # If the section is just a hostname, make it match
            # If the section has a / in it, do a substring match
            if "/" not in sectionhost:
                if sectionhost == urlhost:
                    section = sectionhost
            elif sectionhost in self.url:
                section = sectionhost
            if section:
                log.debug("bugzillarc: Found matching section: %s", section)
                break

        if not section:
            log.debug("bugzillarc: No section found")
            return

        for key, val in cfg.items(section):
            if key == "api_key":
                log.debug("bugzillarc: setting api_key")
                self.api_key = val
            elif key == "user":
                log.debug("bugzillarc: setting user=%s", val)
                self.user = val
            elif key == "password":
                log.debug("bugzillarc: setting password")
                self.password = val
            elif key == "cert":
                log.debug("bugzillarc: setting cert")
                self.cert = val
            else:
                log.debug("bugzillarc: unknown key=%s", key)