gurudesh/pytracebugs huggingface dataset:
# Buggy code
def _fs_to_record_path(path, relative_to=None):
    # type: (text_type, Optional[text_type]) -> RecordPath
    if relative_to is not None:
        path = os.path.relpath(path, relative_to)
    path = path.replace(os.path.sep, "/")
    return cast("RecordPath", path)


# Traceback (ValueError)
Collecting greenlet>=0.4.14
Using cached greenlet-0.4.15-cp36-cp36m-win_amd64.whl (16 kB)
Installing collected packages: greenlet
ERROR: Exception:
Traceback (most recent call last):
File "...\.venv\lib\site-packages\pip\_internal\cli\base_command.py", line 186, in _main
status = self.run(options, args)
File "...\.venv\lib\site-packages\pip\_internal\commands\install.py", line 404, in run
use_user_site=options.use_user_site,
File "...\.venv\lib\site-packages\pip\_internal\req\__init__.py", line 71, in install_given_reqs
**kwargs
File "...\.venv\lib\site-packages\pip\_internal\req\req_install.py", line 815, in install
warn_script_location=warn_script_location,
File "...\.venv\lib\site-packages\pip\_internal\operations\install\wheel.py", line 614, in install_wheel
warn_script_location=warn_script_location,
File "...\.venv\lib\site-packages\pip\_internal\operations\install\wheel.py", line 447, in install_unpacked_wheel
clobber(source, dest, False, fixer=fixer, filter=filter)
File "...\.venv\lib\site-packages\pip\_internal\operations\install\wheel.py", line 412, in clobber
record_installed(srcfile, destfile, changed)
File "...\.venv\lib\site-packages\pip\_internal\operations\install\wheel.py", line 345, in record_installed
newpath = normpath(destfile, lib_dir)
File "...\.venv\lib\site-packages\pip\_internal\operations\install\wheel.py", line 52, in normpath
return os.path.relpath(src, p).replace(os.path.sep, '/')
File "...\.venv\lib\ntpath.py", line 584, in relpath
path_drive, start_drive))
ValueError: path is on mount 'f:', start on mount 'c:'

# Fixed code
def _fs_to_record_path(path, relative_to=None):
    # type: (text_type, Optional[text_type]) -> RecordPath
    if relative_to is not None:
        # On Windows, do not handle relative paths if they belong to different
        # logical disks
        if (
            os.path.splitdrive(path)[0].lower()
            == os.path.splitdrive(relative_to)[0].lower()
        ):
            path = os.path.relpath(path, relative_to)
    path = path.replace(os.path.sep, "/")
    return cast("RecordPath", path)
# Buggy code
def run(self, options, args):
    # type: (Values, List[Any]) -> int
    handlers = {
        "info": self.get_cache_info,
        "list": self.list_cache_items,
        "remove": self.remove_cache_items,
        "purge": self.purge_cache,
    }

    # Determine action
    if not args or args[0] not in handlers:
        logger.error(
            "Need an action ({}) to perform.".format(", ".join(sorted(handlers)))
        )
        return ERROR

    action = args[0]

    # Error handling happens here, not in the action-handlers.
    try:
        handlers[action](options, args[1:])
    except PipError as e:
        logger.error(e.args[0])
        return ERROR

    return SUCCESS


# Traceback (TypeError)
pip cache info
ERROR: Exception:
Traceback (most recent call last):
File "c:\program files\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in _main
status = self.run(options, args)
File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 62, in run
handlers[action](options, args[1:])
File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 74, in get_cache_info
num_packages = len(self._find_wheels(options, '*'))
File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 145, in _find_wheels
wheel_dir = self._wheels_cache_dir(options)
File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 141, in _wheels_cache_dir
return os.path.join(options.cache_dir, 'wheels')
File "c:\program files\python38\lib\ntpath.py", line 78, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not bool

# Fixed code
def run(self, options, args):
    # type: (Values, List[Any]) -> int
    handlers = {
        "info": self.get_cache_info,
        "list": self.list_cache_items,
        "remove": self.remove_cache_items,
        "purge": self.purge_cache,
    }

    if not options.cache_dir:
        logger.error("pip cache commands can not function since cache is disabled.")
        return ERROR

    # Determine action
    if not args or args[0] not in handlers:
        logger.error(
            "Need an action ({}) to perform.".format(", ".join(sorted(handlers)))
        )
        return ERROR

    action = args[0]

    # Error handling happens here, not in the action-handlers.
    try:
        handlers[action](options, args[1:])
    except PipError as e:
        logger.error(e.args[0])
        return ERROR

    return SUCCESS
# Buggy code
def __init__(self, use_interactive=None):
    # type: (bool) -> None
    if use_interactive is None:
        use_interactive = sys.stdin.isatty()
    self.use_interactive = use_interactive

    # This member is used to cache the fetched version of the current
    # ``svn`` client.
    # Special value definitions:
    #   None: Not evaluated yet.
    #   Empty tuple: Could not parse version.
    self._vcs_version = None  # type: Optional[Tuple[int, ...]]

    super(Subversion, self).__init__()


# Traceback (AttributeError)
$ virtualenv -p python3 env
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/env/bin/python3
Also creating executable in /tmp/env/bin/python
Installing setuptools, pip, wheel...
done.
$ source env/bin/activate
(env) $ python -c 'import pip._internal as pip' 0<&amp;-
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 11, in <module>
from pip._internal.commands import (
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 21, in <module>
from pip._internal.download import PipSession
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/download.py", line 47, in <module>
from pip._internal.vcs import vcs
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/vcs/__init__.py", line 12, in <module>
import pip._internal.vcs.subversion  # noqa: F401
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/vcs/subversion.py", line 314, in <module>
vcs.register(Subversion)
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py", line 165, in register
self._registry[cls.name] = cls()
File "/tmp/env/lib/python3.7/site-packages/pip/_internal/vcs/subversion.py", line 180, in __init__
use_interactive = sys.stdin.isatty()
AttributeError: 'NoneType' object has no attribute 'isatty'
(env) $

# Fixed code
def __init__(self, use_interactive=None):
    # type: (bool) -> None
    if use_interactive is None:
        use_interactive = is_console_interactive()
    self.use_interactive = use_interactive

    # This member is used to cache the fetched version of the current
    # ``svn`` client.
    # Special value definitions:
    #   None: Not evaluated yet.
    #   Empty tuple: Could not parse version.
    self._vcs_version = None  # type: Optional[Tuple[int, ...]]

    super(Subversion, self).__init__()
# Buggy code
def is_hash_allowed(self, hashes):
    # type: (Hashes) -> bool
    """
    Return True if the link has a hash and it is allowed.
    """
    if not self.has_hash:
        return False
    # Assert non-None so mypy knows self.hash_name and self.hash are str.
    assert self.hash_name is not None
    assert self.hash is not None

    return hashes.is_hash_allowed(self.hash_name, hex_digest=self.hash)


# Traceback (AttributeError)
(env) project (develop) $ pip list --outdated --format=columns
ERROR: Exception:
Traceback (most recent call last):
File "/project/env/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 188, in main
status = self.run(options, args)
File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 156, in run
packages = self.get_outdated(packages, options)
File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 164, in get_outdated
dist for dist in self.iter_packages_latest_infos(packages, options)
File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 164, in <listcomp>
dist for dist in self.iter_packages_latest_infos(packages, options)
File "/project/env/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 195, in iter_packages_latest_infos
best_candidate = evaluator.get_best_candidate(all_candidates)
File "/project/env/lib/python3.6/site-packages/pip/_internal/index.py", line 729, in get_best_candidate
best_candidate = max(candidates, key=self._sort_key)
File "/project/env/lib/python3.6/site-packages/pip/_internal/index.py", line 710, in _sort_key
has_allowed_hash = int(link.is_hash_allowed(self._hashes))
File "/project/env/lib/python3.6/site-packages/pip/_internal/models/link.py", line 213, in is_hash_allowed
return hashes.is_hash_allowed(self.hash_name, hex_digest=self.hash)
AttributeError: 'NoneType' object has no attribute 'is_hash_allowed'

# Fixed code
def is_hash_allowed(self, hashes):
    # type: (Optional[Hashes]) -> bool
    """
    Return True if the link has a hash and it is allowed.
    """
    if hashes is None or not self.has_hash:
        return False
    # Assert non-None so mypy knows self.hash_name and self.hash are str.
    assert self.hash_name is not None
    assert self.hash is not None

    return hashes.is_hash_allowed(self.hash_name, hex_digest=self.hash)
# Buggy code
def __init__(self, cache_dir):
    self.statefile_path = os.path.join(cache_dir, "selfcheck.json")

    # Load the existing state
    try:
        with open(self.statefile_path) as statefile:
            self.state = json.load(statefile)[sys.prefix]
    except (IOError, ValueError, KeyError):
        self.state = {}


# Traceback (TypeError)
pip install --no-cache-dir --verbose wheel
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Created temporary directory: C:\Users\User\AppData\Local\Temp\pip-ephem-wheel-cache-2e5wmnq3
Created temporary directory: C:\Users\User\AppData\Local\Temp\pip-req-tracker-gnigbooj
Created requirements tracker 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-req-tracker-gnigbooj'
Created temporary directory: C:\Users\User\AppData\Local\Temp\pip-install-u77xlkpb
Requirement already satisfied: wheel in c:\users\user\prj\pip\venv\lib\site-packages (0.31.1)
Cleaning up...
Removed build tracker 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-req-tracker-gnigbooj'
There was an error checking the latest version of pip
Traceback (most recent call last):
File "c:\users\user\prj\pip\src\pip\_internal\utils\outdated.py", line 90, in pip_version_check
state = SelfCheckState(cache_dir=options.cache_dir)
File "c:\users\user\prj\pip\src\pip\_internal\utils\outdated.py", line 25, in __init__
self.statefile_path = os.path.join(cache_dir, "selfcheck.json")
File "C:\Users\user\prj\pip\venv\lib\ntpath.py", line 76, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not bool

# Fixed code
def __init__(self, cache_dir):
    self.state = {}
    self.statefile_path = None

    # Try to load the existing state
    if cache_dir:
        self.statefile_path = os.path.join(cache_dir, "selfcheck.json")
        try:
            with open(self.statefile_path) as statefile:
                self.state = json.load(statefile)[sys.prefix]
        except (IOError, ValueError, KeyError):
            # Explicitly suppressing exceptions, since we don't want to
            # error out if the cache file is invalid.
            pass
# Buggy code
def uninstallation_paths(dist):
    """
    Yield all the uninstallation paths for dist based on RECORD-without-.pyc

    Yield paths to all the files in RECORD. For each .py file in RECORD, add
    the .pyc in the same directory.

    UninstallPathSet.add() takes care of the __pycache__ .pyc.
    """
    r = csv.reader(FakeFile(dist.get_metadata_lines("RECORD")))
    for row in r:
        path = os.path.join(dist.location, row[0])
        yield path
        if path.endswith(".py"):
            dn, fn = os.path.split(path)
            base = fn[:-3]
            path = os.path.join(dn, base + ".pyc")
            yield path


# Traceback (ImportError)
$python -O -c "import requests"
$python -c "import requests"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named requests

# Fixed code
def uninstallation_paths(dist):
    """
    Yield all the uninstallation paths for dist based on RECORD-without-.py[co]

    Yield paths to all the files in RECORD. For each .py file in RECORD, add
    the .pyc and .pyo in the same directory.

    UninstallPathSet.add() takes care of the __pycache__ .py[co].
    """
    r = csv.reader(FakeFile(dist.get_metadata_lines("RECORD")))
    for row in r:
        path = os.path.join(dist.location, row[0])
        yield path
        if path.endswith(".py"):
            dn, fn = os.path.split(path)
            base = fn[:-3]
            path = os.path.join(dn, base + ".pyc")
            yield path
            path = os.path.join(dn, base + ".pyo")
            yield path
# Buggy code
def __repr__(self):
    """Return repr of all info"""
    return (
        "LinuxDistribution("
        "os_release_file={0!r}, "
        "distro_release_file={1!r}, "
        "_os_release_info={2!r}, "
        "_lsb_release_info={3!r}, "
        "_distro_release_info={4!r})".format(
            self.os_release_file,
            self.distro_release_file,
            self._os_release_info,
            self._lsb_release_info,
            self._distro_release_info,
        )
    )


# Traceback (UnicodeDecodeError)
51_billappxz%pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.1)
setuptools (38.2.4)
Traceback (most recent call last):
File "/data01/billappxz/scripts/ThirdParty/python27/bin/pip", line 11, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/_vendor/distro.py", line 922, in _get_lsb_release_info
stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')
File "/data01/billappxz/scripts/ThirdParty/python27/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd5 in position 24: invalid continuation byte

# Fixed code
def __repr__(self):
    """Return repr of all info"""
    return (
        "LinuxDistribution("
        "os_release_file={self.os_release_file!r}, "
        "distro_release_file={self.distro_release_file!r}, "
        "include_lsb={self.include_lsb!r}, "
        "_os_release_info={self._os_release_info!r}, "
        "_lsb_release_info={self._lsb_release_info!r}, "
        "_distro_release_info={self._distro_release_info!r})".format(self=self)
    )
# Buggy code
def _base_setup_args(self, req):
    return [
        sys.executable,
        "-u",
        "-c",
        "import setuptools;__file__=%r;"
        "exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), "
        "__file__, 'exec'))" % req.setup_py,
    ] + list(self.global_options)


# Traceback (UnicodeDecodeError)
$ pip wheel --wheel-dir .  -v pysmfDownloading/unpacking pysmf
Downloading pysmf-0.1.1.tar.gz (50kB):
Downloading from URL https://pypi.python.org/packages/source/p/pysmf/pysmf-0.1.1.tar.gz#md5=8354f3cd7752b12e2668d4ed9aaa25c9 (from https://pypi.python.org/simple/pysmf/)
...Downloading pysmf-0.1.1.tar.gz (50kB): 50kB downloaded
Storing download in cache at ./.pip_download_cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpysmf%2Fpysmf-0.1.1.tar.gz
Running setup.py (path:/home/chris/tmp/pip_build_chris/pysmf/setup.py) egg_info for package pysmf
running egg_info
creating pip-egg-info/pysmf.egg-info
writing pip-egg-info/pysmf.egg-info/PKG-INFO
writing top-level names to pip-egg-info/pysmf.egg-info/top_level.txt
writing dependency_links to pip-egg-info/pysmf.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/pysmf.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found

reading manifest file 'pip-egg-info/pysmf.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/pysmf.egg-info/SOURCES.txt'
Building wheels for collected packages: pysmf
Running setup.py bdist_wheel for pysmf
Destination directory: /home/chris
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1623: ordinal not in range(128)
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/chris/tmp/pip_build_chris/pysmf/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /home/chris:
Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode

return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1623: ordinal not in range(128)

----------------------------------------
Failed building wheel for pysmf
Failed to build pysmf
Cleaning up...
Removing temporary dir /home/chris/tmp/pip_build_chris...

# Fixed code
def _base_setup_args(self, req):
    return [sys.executable, "-u", "-c", SETUPTOOLS_SHIM % req.setup_py] + list(
        self.global_options
    )
# Buggy code
def get_src_requirement(self, dist, location, find_tags):
    repo = self.get_url(location)
    if not repo.lower().startswith("git:"):
        repo = "git+" + repo
    egg_project_name = dist.egg_name().split("-", 1)[0]
    if not repo:
        return None
    current_rev = self.get_revision(location)
    refs = self.get_refs(location)
    # refs maps names to commit hashes; we need the inverse
    # if multiple names map to a single commit, we pick the first one
    # alphabetically
    names_by_commit = {}
    for ref, commit in sorted(refs.items()):
        if commit not in names_by_commit:
            names_by_commit[commit] = ref

    if current_rev in names_by_commit:
        # It's a tag
        full_egg_name = "%s-%s" % (egg_project_name, names_by_commit[current_rev])
    else:
        full_egg_name = "%s-dev" % egg_project_name

    return "%s@%s#egg=%s" % (repo, current_rev, full_egg_name)


# Traceback (ValueError)
Exception:
Traceback (most recent call last):
File "lib/python2.7/site-packages/pip/basecommand.py", line 134, in main
status = self.run(options, args)
File "lib/python2.7/site-packages/pip/commands/install.py", line 220, in run
for req in parse_requirements(filename, finder=finder, options=options):
File "lib/python2.7/site-packages/pip/req.py", line 1454, in parse_requirements
line, comes_from=comes_from, default_vcs=options.default_vcs if options else None)
File "lib/python2.7/site-packages/pip/req.py", line 85, in from_editable
res = cls(name, comes_from, source_dir=source_dir, editable=True, url=url, prereleases=True)
File "lib/python2.7/site-packages/pip/req.py", line 43, in __init__
req = pkg_resources.Requirement.parse(req)
File "lib/python2.7/site-packages/pkg_resources.py", line 2914, in parse
reqs = list(parse_requirements(s))
File "lib/python2.7/site-packages/pkg_resources.py", line 2839, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "lib/python2.7/site-packages/pkg_resources.py", line 2807, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'django_timezone_field-origin/develop', 'at', '/develop')

# Fixed code
def get_src_requirement(self, dist, location, find_tags):
    repo = self.get_url(location)
    if not repo.lower().startswith("git:"):
        repo = "git+" + repo
    egg_project_name = dist.egg_name().split("-", 1)[0]
    if not repo:
        return None
    current_rev = self.get_revision(location)
    refs = self.get_refs(location)
    # refs maps names to commit hashes; we need the inverse
    # if multiple names map to a single commit, we pick the first one
    # alphabetically
    names_by_commit = {}
    for ref, commit in sorted(refs.items()):
        if commit not in names_by_commit:
            names_by_commit[commit] = ref

    if current_rev in names_by_commit:
        # It's a tag
        name = names_by_commit[current_rev]
        full_egg_name = "%s-%s" % (egg_project_name, self.escape_egg_surname(name))
    else:
        full_egg_name = "%s-dev" % egg_project_name

    return "%s@%s#egg=%s" % (repo, current_rev, full_egg_name)
# Buggy code
def unpack_url(self, link, location, download_dir=None, only_download=False):
    if download_dir is None:
        download_dir = self.download_dir

    # non-editable vcs urls
    if is_vcs_url(link):
        if only_download:
            loc = download_dir
        else:
            loc = location
        unpack_vcs_link(link, loc, only_download)

    # file urls
    elif is_file_url(link):
        unpack_file_url(link, location, download_dir)
        if only_download:
            write_delete_marker_file(location)

    # http urls
    else:
        unpack_http_url(
            link,
            location,
            download_dir,
            self.session,
        )
        if only_download:
            write_delete_marker_file(location)


# Traceback (IOError)
(virtualenv)root@klisrv10:/srv/www/django/development.yupifoods.com# pip install --no-install --download=./virtualenv-pip-package-downloads/ git+git://github.com/django/django.git
Downloading/unpacking git+git://github.com/django/django.git
Cloning git://github.com/django/django.git to /tmp/pip-pfx_Cq-export
Running setup.py egg_info for package from git+git://github.com/django/django.git
Traceback (most recent call last):
File "<string>", line 16, in <module>
IOError: [Errno 2] No such file or directory: '/tmp/pip-lrMKsp-build/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "<string>", line 16, in <module>

IOError: [Errno 2] No such file or directory: '/tmp/pip-lrMKsp-build/setup.py'

# Fixed code
def unpack_url(self, link, location, download_dir=None, only_download=False):
    if download_dir is None:
        download_dir = self.download_dir

    # non-editable vcs urls
    if is_vcs_url(link):
        unpack_vcs_link(link, location, only_download)

    # file urls
    elif is_file_url(link):
        unpack_file_url(link, location, download_dir)
        if only_download:
            write_delete_marker_file(location)

    # http urls
    else:
        unpack_http_url(
            link,
            location,
            download_dir,
            self.session,
        )
        if only_download:
            write_delete_marker_file(location)
# Buggy code
def get_url_rev(self):
    """
    Returns the correct repository URL and revision by parsing the given
    repository URL
    """
    url = self.url.split("+", 1)[1]
    scheme, netloc, path, query, frag = urlparse.urlsplit(url)
    rev = None
    if "@" in path:
        path, rev = path.rsplit("@", 1)
    url = urlparse.urlunsplit((scheme, netloc, path, query, ""))
    return url, rev


# Traceback (IndexError)
Downloading/unpacking fixture-generator from git://github.com/alex/django-fixture-generator.git (from -r requirements/development.txt (line 3))
Exception:
Traceback (most recent call last):
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/basecommand.py", line 126, in main
self.run(options, args)
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/commands/install.py", line 223, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 961, in prepare_files
self.unpack_url(url, location, self.is_download)
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 1073, in unpack_url
return unpack_vcs_link(link, location, only_download)
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/download.py", line 293, in unpack_vcs_link
vcs_backend.unpack(location)
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/__init__.py", line 225, in unpack
self.obtain(location)
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/git.py", line 97, in obtain
url, rev = self.get_url_rev()
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/git.py", line 183, in get_url_rev
url, rev = super(Git, self).get_url_rev()
File "/home/alex/.virtualenvs/tracebin/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/vcs/__init__.py", line 117, in get_url_rev
url = self.url.split('+', 1)[1]
IndexError: list index out of range

# Fixed code
def get_url_rev(self):
    """
    Returns the correct repository URL and revision by parsing the given
    repository URL
    """
    error_message = "Sorry, '{}' is a malformed url. In requirements files, the \
format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyApp"
    assert "+" in self.url, error_message.format(self.url)
    url = self.url.split("+", 1)[1]
    scheme, netloc, path, query, frag = urlparse.urlsplit(url)
    rev = None
    if "@" in path:
        path, rev = path.rsplit("@", 1)
    url = urlparse.urlunsplit((scheme, netloc, path, query, ""))
    return url, rev
# Buggy code
def get_storage_client(credentials: dict = None, project: str = None):
    """
    Utility function for instantiating a Google Storage Client from a given set of credentials.

    Args:
        - credentials (dict, optional): a dictionary of Google credentials used to initialize the Client; if
            not provided, will attempt to load the Client using ambient environment settings
        - project (str, optional): the Google project to point the Client to; if not provided, Client defaults
            will be used

    Returns:
        - Client: an initialized and authenticated Google Client
    """
    return get_google_client(storage, credentials=credentials, project=project)


# Traceback (ImportError)
Unexpected error: ImportError("cannot import name 'bigquery' from 'google.cloud' (unknown location)")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/prefect/engine/task_runner.py", line 986, in get_task_run_state
result = self.result.write(value, filename="output", **prefect.context)
File "/usr/local/lib/python3.7/site-packages/prefect/engine/results/gcs_result.py", line 73, in write
self.gcs_bucket.blob(new.location).upload_from_string(binary_data)
File "/usr/local/lib/python3.7/site-packages/prefect/engine/results/gcs_result.py", line 35, in gcs_bucket
from prefect.utilities.gcp import get_storage_client
File "/usr/local/lib/python3.7/site-packages/prefect/utilities/gcp.py", line 6, in <module>
from google.cloud import bigquery, storage
ImportError: cannot import name 'bigquery' from 'google.cloud' (unknown location)

# Fixed code
def get_storage_client(credentials: dict = None, project: str = None):
    """
    Utility function for instantiating a Google Storage Client from a given set of credentials.

    Args:
        - credentials (dict, optional): a dictionary of Google credentials used to initialize the Client; if
            not provided, will attempt to load the Client using ambient environment settings
        - project (str, optional): the Google project to point the Client to; if not provided, Client defaults
            will be used

    Returns:
        - Client: an initialized and authenticated Google Client
    """
    from google.cloud import storage

    return get_google_client(storage, credentials=credentials, project=project)
# Buggy code
def get_bigquery_client(credentials: dict = None, project: str = None):
    """
    Utility function for instantiating a Google BigQuery Client from a given set of credentials.

    Args:
        - credentials (dict, optional): a dictionary of Google credentials used to initialize the Client; if
            not provided, will attempt to load the Client using ambient environment settings
        - project (str, optional): the Google project to point the Client to; if not provided, Client defaults
            will be used

    Returns:
        - Client: an initialized and authenticated Google Client
    """
    return get_google_client(bigquery, credentials=credentials, project=project)


# Traceback (ImportError)
Unexpected error: ImportError("cannot import name 'bigquery' from 'google.cloud' (unknown location)")
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/prefect/engine/task_runner.py", line 986, in get_task_run_state
result = self.result.write(value, filename="output", **prefect.context)
File "/usr/local/lib/python3.7/site-packages/prefect/engine/results/gcs_result.py", line 73, in write
self.gcs_bucket.blob(new.location).upload_from_string(binary_data)
File "/usr/local/lib/python3.7/site-packages/prefect/engine/results/gcs_result.py", line 35, in gcs_bucket
from prefect.utilities.gcp import get_storage_client
File "/usr/local/lib/python3.7/site-packages/prefect/utilities/gcp.py", line 6, in <module>
from google.cloud import bigquery, storage
ImportError: cannot import name 'bigquery' from 'google.cloud' (unknown location)

# Fixed code
def get_bigquery_client(credentials: dict = None, project: str = None):
    """
    Utility function for instantiating a Google BigQuery Client from a given set of credentials.

    Args:
        - credentials (dict, optional): a dictionary of Google credentials used to initialize the Client; if
            not provided, will attempt to load the Client using ambient environment settings
        - project (str, optional): the Google project to point the Client to; if not provided, Client defaults
            will be used

    Returns:
        - Client: an initialized and authenticated Google Client
    """
    from google.cloud import bigquery

    return get_google_client(bigquery, credentials=credentials, project=project)
# Buggy code
def __init__(self, bucket: str, aws_credentials_secret: str = None) -> None:
    self.bucket = bucket
    self.aws_credentials_secret = aws_credentials_secret
    super().__init__()


# Traceback (AttributeError)
Unexpected error: AttributeError("'S3ResultHandler' object has no attribute '_client'")
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/prefect/engine/task_runner.py", line 925, in get_task_run_state
state._result.store_safe_value()
File "/opt/conda/lib/python3.7/site-packages/prefect/engine/result.py", line 121, in store_safe_value
value = self.result_handler.write(self.value)
File "/opt/conda/lib/python3.7/site-packages/prefect/engine/result_handlers/s3_result_handler.py", line 112, in write
self.client.upload_fileobj(stream, Bucket=self.bucket, Key=uri)
File "/opt/conda/lib/python3.7/site-packages/prefect/engine/result_handlers/s3_result_handler.py", line 77, in client
return self._client
AttributeError: 'S3ResultHandler' object has no attribute '_client'

# Fixed code
def __init__(self, bucket: str, aws_credentials_secret: str = None) -> None:
    self.bucket = bucket
    self.aws_credentials_secret = aws_credentials_secret
    self._client = None
    super().__init__()
# Buggy code
def add_flow(self, flow: "prefect.core.flow.Flow") -> str:
    """
    Method for adding a new flow to this Storage object.

    Args:
        - flow (Flow): a Prefect Flow to add

    Returns:
        - str: the location of the newly added flow in this Storage object
    """
    if flow.name in self:
        raise ValueError(
            'Name conflict: Flow with the name "{}" is already present in this storage.'.format(
                flow.name
            )
        )
    flow_path = "/root/.prefect/{}.prefect".format(flow.name.replace(" ", ""))
    self.flows[flow.name] = flow_path
    self._flows[flow.name] = flow  # needed prior to build
    return flow_path


# Traceback (prefect.utilities.exceptions.SerializationError)
Step 1/9 : FROM python:3.6
---> 2bb3204ab1d1
Step 2/9 : RUN pip install pip --upgrade
---> Using cache
---> 4d8b101e2933
Step 3/9 : RUN pip install wheel
---> Using cache
---> 7389d69ba240
Step 4/9 : RUN mkdir /root/.prefect/
---> Using cache
---> 10619fcde458
Step 5/9 : COPY Test Flow.flow /root/.prefect/TestFlow.prefect
Traceback (most recent call last):
File "managed_agent_testing.py", line 15, in <module>
f.deploy(project_name="Test Project")
File "/Users/josh/Desktop/code/prefect/src/prefect/core/flow.py", line 1361, in deploy
set_schedule_inactive=set_schedule_inactive,
File "/Users/josh/Desktop/code/prefect/src/prefect/client/client.py", line 357, in deploy
serializedFlow=flow.serialize(build=build),
File "/Users/josh/Desktop/code/prefect/src/prefect/core/flow.py", line 1116, in serialize
storage = self.storage.build()  # type: Optional[Storage]
File "/Users/josh/Desktop/code/prefect/src/prefect/environments/storage/docker.py", line 170, in build
image_name, image_tag = self.build_image(push=push)
File "/Users/josh/Desktop/code/prefect/src/prefect/environments/storage/docker.py", line 219, in build_image
"Your flow failed to deserialize in the container; please ensure that all necessary files and dependencies have been included."
prefect.utilities.exceptions.SerializationError: Your flow failed to deserialize in the container; please ensure that all necessary files and dependencies have been included.

# Fixed code
def add_flow(self, flow: "prefect.core.flow.Flow") -> str:
    """
    Method for adding a new flow to this Storage object.

    Args:
        - flow (Flow): a Prefect Flow to add

    Returns:
        - str: the location of the newly added flow in this Storage object
    """
    if flow.name in self:
        raise ValueError(
            'Name conflict: Flow with the name "{}" is already present in this storage.'.format(
                flow.name
            )
        )
    flow_path = "/root/.prefect/{}.prefect".format(slugify(flow.name))
    self.flows[flow.name] = flow_path
    self._flows[flow.name] = flow  # needed prior to build
    return flow_path
# Buggy code
def _connect_to_v1(self):
    line = self._read_line()
    match = re.match("^SNIPPET SERVING, PORT ([0-9]+)$", line)
    if not match:
        raise ProtocolVersionError(line)
    self.device_port = int(match.group(1))

    # Forward the device port to a new host port, and connect to that port
    self.host_port = utils.get_available_host_port()
    self._adb.forward(["tcp:%d" % self.host_port, "tcp:%d" % self.device_port])
    self.connect()


# Traceback (TypeError)
$ snippet_shell.py --mbs
s.logINFO:root:[AndroidDevice|HT67K0300103] Launching snippet apk com.google.android.mobly.snippet.bundled with protocol v1
VTraceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/snippet_shell.py", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/angli/Developer/mobly/tools/snippet_shell.py", line 84, in <module>
SnippetShell(package).main(args.serial)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/jsonrpc_shell_base.py", line 88, in main
self.start_console()
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/jsonrpc_shell_base.py", line 73, in start_console
self._start_services(console_env)
File "/Users/angli/Developer/mobly/tools/snippet_shell.py", line 43, in _start_services
self._ad.load_snippet(name='snippet', package=self._package)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device.py", line 646, in load_snippet
client.start_app_and_connect()
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/snippet_client.py", line 112, in start_app_and_connect
line)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 172, in match
return _compile(pattern, flags).match(string)
TypeError: cannot use a string pattern on a bytes-like object

# Fixed code
def _connect_to_v1(self):
    line = self._read_protocol_line()
    match = re.match("^SNIPPET SERVING, PORT ([0-9]+)$", line)
    if not match:
        raise jsonrpc_client_base.AppStartError(line)
    self.device_port = int(match.group(1))

    # Forward the device port to a new host port, and connect to that port
    self.host_port = utils.get_available_host_port()
    self._adb.forward(["tcp:%d" % self.host_port, "tcp:%d" % self.device_port])
    self.connect()
# Buggy code
def _do_start_app(self):
    """Overrides superclass."""
    self._adb.shell(_LAUNCH_CMD.format(self.device_port))


# Traceback (AttributeError)
$ snippet_shell.py com.google.android.mobly.snippet.bundled
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/snippet_shell.py", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/angli/Developer/mobly/tools/snippet_shell.py", line 64, in <module>
SnippetShell(args.package[0]).main(args.serial)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/jsonrpc_shell_base.py", line 91, in main
self.start_console()
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/jsonrpc_shell_base.py", line 76, in start_console
self._start_services(console_env)
File "/Users/angli/Developer/mobly/tools/snippet_shell.py", line 41, in _start_services
self._ad.load_snippet(name='snippet', package=self._package)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device.py", line 629, in load_snippet
self._start_jsonrpc_client(client)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device.py", line 660, in _start_jsonrpc_client
client.check_app_installed()
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/snippet_client.py", line 110, in check_app_installed
target_name = match.group(3)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def _do_start_app(self):
    """Overrides superclass."""
    self._adb.shell(_LAUNCH_CMD % self.device_port)
# Buggy code
def check_app_installed(self):
    """Overrides superclass."""
    if not self._adb_grep_wrapper(
        "pm list package | grep com.googlecode.android_scripting"
    ):
        raise jsonrpc_client_base.AppStartError(
            "%s is not installed on %s" % (self.app_name, self._adb.serial)
        )


# Traceback (AttributeError)
$ snippet_shell.py com.google.android.mobly.snippet.bundled
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/snippet_shell.py", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/angli/Developer/mobly/tools/snippet_shell.py", line 64, in <module>
SnippetShell(args.package[0]).main(args.serial)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/jsonrpc_shell_base.py", line 91, in main
self.start_console()
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/jsonrpc_shell_base.py", line 76, in start_console
self._start_services(console_env)
File "/Users/angli/Developer/mobly/tools/snippet_shell.py", line 41, in _start_services
self._ad.load_snippet(name='snippet', package=self._package)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device.py", line 629, in load_snippet
self._start_jsonrpc_client(client)
File "/Users/angli/Developer/mobly/mobly/controllers/android_device.py", line 660, in _start_jsonrpc_client
client.check_app_installed()
File "/Users/angli/Developer/mobly/mobly/controllers/android_device_lib/snippet_client.py", line 110, in check_app_installed
target_name = match.group(3)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def check_app_installed(self):
    """Overrides superclass."""
    out = self._adb("pm list package")
    if not self._grep("com.googlecode.android_scripting", out):
        raise jsonrpc_client_base.AppStartError(
            "%s is not installed on %s" % (self.app_name, self._adb.serial)
        )
# Buggy code
def asDict(self):
    # This return value should match the kwargs to
    # SourceStampsConnectorComponent.findSourceStampId
    result = {}
    for attr in self.ATTRS:
        result[attr] = self._ssdict.get(attr)

    patch = self._ssdict.get("patch") or {}
    for attr in self.PATCH_ATTRS:
        result["patch_{}".format(attr)] = patch.get(attr)

    assert all(
        isinstance(val, (str, int, type(None))) for attr, val in result.items()
    ), result
    return result


# Traceback (builtins.AssertionError)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1442, in gotResult
_inlineCallbacks(r, g, deferred)
File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
result = g.send(result)
File "/home/cit/.local/lib/python3.6/site-packages/buildbot/process/buildstep.py", line 567, in startStep
self.results = yield self.run()
File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1532, in unwindGenerator
return _inlineCallbacks(None, gen, Deferred())
--- <exception caught here> ---
File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
result = g.send(result)
File "/home/cit/.local/lib/python3.6/site-packages/buildbot/steps/trigger.py", line 257, in run
ss_for_trigger = self.prepareSourcestampListForTrigger()
File "/home/cit/.local/lib/python3.6/site-packages/buildbot/steps/trigger.py", line 167, in prepareSourcestampListForTrigger
ss_for_trigger[ss.codebase] = ss.asDict()
File "/home/cit/.local/lib/python3.6/site-packages/buildbot/process/buildrequest.py", line 137, in asDict
), result
builtins.AssertionError: {'branch': None, 'revision': '8a3fad6b5f844704f678af71d10fdc822ff11641', 'repository': 'ssh://some-private-git-host/infra/bb-test.git', 'project': '', 'codebase': '', 'patch_level': 1, 'patch_body': b':100755 100755 1465b4e... 0000000... M\ttest\n\ndiff --git a/test b/test\nindex 1465b4e..c8548bb 100755\n--- a/test\n+++ b/test\n@@ -4,5 +4,5 @@ echo "This is a fake test to be run by a test buildbot"\n \n echo "Still not actually running any tests"\n \n-echo "NO TESTS PASSED!!!"\n+echo "NO TESTS PASSED, BUT ALL TESTS PASSED!!!"\n \n', 'patch_subdir': '', 'patch_author': 'ehohenstein', 'patch_comment': 'ehohenstein'}

# Fixed code
def asDict(self):
    # This return value should match the kwargs to
    # SourceStampsConnectorComponent.findSourceStampId
    result = {}
    for attr in self.ATTRS:
        result[attr] = self._ssdict.get(attr)

    patch = self._ssdict.get("patch") or {}
    for patch_attr, attr in self.PATCH_ATTRS:
        result[patch_attr] = patch.get(attr)

    assert all(
        isinstance(val, (str, int, bytes, type(None))) for attr, val in result.items()
    ), result
    return result
# Buggy code
def process(self, request):
    payload = self._get_payload(request)

    event_type = request.getHeader(_HEADER_EVENT)
    event_type = bytes2NativeString(event_type)
    log.msg("X-GitHub-Event: {}".format(event_type), logLevel=logging.DEBUG)

    handler = getattr(self, "handle_{}".format(event_type), None)

    if handler is None:
        raise ValueError("Unknown event: {}".format(event_type))

    result = yield defer.maybeDeferred(lambda: handler(payload, event_type))
    defer.returnValue(result)


# Traceback (builtins.KeyError)
Traceback (most recent call last):
File "/opt/buildbot/lib/python3.5/site-packages/twisted/web/server.py", line 235, in render
body = resrc.render(self)
File "/opt/buildbot/lib/python3.5/site-packages/twisted/web/resource.py", line 250, in render
return m(request)
File "/opt/buildbot/lib/python3.5/site-packages/buildbot/www/change_hook.py", line 81, in render_POST
d = self.getAndSubmitChanges(request)
File "/opt/buildbot/lib/python3.5/site-packages/twisted/internet/defer.py", line 1532, in unwindGenerator
return _inlineCallbacks(None, gen, Deferred())
--- <exception caught here> ---
File "/opt/buildbot/lib/python3.5/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/opt/buildbot/lib/python3.5/site-packages/twisted/python/failure.py", line 393, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/opt/buildbot/lib/python3.5/site-packages/buildbot/www/change_hook.py", line 107, in getAndSubmitChanges
changes, src = yield self.getChanges(request)
builtins.KeyError: 'payload'

# Fixed code
def process(self, request):
    payload = self._get_payload(request)

    event_type = request.getHeader(_HEADER_EVENT)
    event_type = bytes2unicode(event_type)
    log.msg("X-GitHub-Event: {}".format(event_type), logLevel=logging.DEBUG)

    handler = getattr(self, "handle_{}".format(event_type), None)

    if handler is None:
        raise ValueError("Unknown event: {}".format(event_type))

    result = yield defer.maybeDeferred(lambda: handler(payload, event_type))
    defer.returnValue(result)