# Buggy code
def get_file_content(url, comes_from=None):
    """Gets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content)"""
    match = _scheme_re.search(url)
    if match:
        scheme = match.group(1).lower()
        if scheme == "file" and comes_from and comes_from.startswith("http"):
            raise InstallationError(
                "Requirements file %s references URL %s, which is local"
                % (comes_from, url)
            )
        if scheme == "file":
            path = url.split(":", 1)[1]
            path = path.replace("\\", "/")
            match = _url_slash_drive_re.match(path)
            if match:
                path = match.group(1) + ":" + path.split("|", 1)[1]
            path = urllib.unquote(path)
            if path.startswith("/"):
                path = "/" + path.lstrip("/")
            url = path
        else:
            ## FIXME: catch some errors
            resp = urlopen(url)
            return geturl(resp), resp.read()
    try:
        f = open(url)
        content = f.read()
    except IOError:
        e = sys.exc_info()[1]
        raise InstallationError("Could not open requirements file: %s" % str(e))
    else:
        f.close()
    return url, content


# Traceback (TypeError)
$ pip install -r http://some.web.com/requirements.txt
Exception:
Traceback (most recent call last):
File "..../lib/python3.2/site-packages/pip-1.2.1-py3.2.egg/pip/basecommand.py", line 107, in main
status = self.run(options, args)
File "..../lib/python3.2/site-packages/pip-1.2.1-py3.2.egg/pip/commands/install.py", line 230, in run
for req in parse_requirements(filename, finder=finder, options=options):
File "..../lib/python3.2/site-packages/pip-1.2.1-py3.2.egg/pip/req.py", line 1280, in parse_requirements
if not line or line.startswith('#'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

# Fixed code
def get_file_content(url, comes_from=None):
    """Gets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content).  Content is unicode."""
    match = _scheme_re.search(url)
    if match:
        scheme = match.group(1).lower()
        if scheme == "file" and comes_from and comes_from.startswith("http"):
            raise InstallationError(
                "Requirements file %s references URL %s, which is local"
                % (comes_from, url)
            )
        if scheme == "file":
            path = url.split(":", 1)[1]
            path = path.replace("\\", "/")
            match = _url_slash_drive_re.match(path)
            if match:
                path = match.group(1) + ":" + path.split("|", 1)[1]
            path = urllib.unquote(path)
            if path.startswith("/"):
                path = "/" + path.lstrip("/")
            url = path
        else:
            ## FIXME: catch some errors
            resp = urlopen(url)
            encoding = get_http_message_param(resp.headers, "charset", "utf-8")
            return geturl(resp), resp.read().decode(encoding)
    try:
        f = open(url)
        content = f.read()
    except IOError:
        e = sys.exc_info()[1]
        raise InstallationError("Could not open requirements file: %s" % str(e))
    else:
        f.close()
    return url, content