gurudesh/pytracebugs huggingface dataset:
# Buggy code
def dump_map(self):
    result = dict((k, v) for k, v in iteritems(vars(self)) if not k.startswith("_"))
    result.update(
        exception_type=text_type(type(self)),
        exception_name=self.__class__.__name__,
        message=text_type(self),
        error=repr(self),
        caused_by=repr(self._caused_by),
        **self._kwargs,
    )
    return result


# Traceback (ValueError)
$ source ~/anaconda/bin/activate
Traceback (most recent call last):
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 458
Logged from file exceptions.py, line 770
$ echo $ZSH_VERSION
5.3.1

# Fixed code
def dump_map(self):
    result = dict((k, v) for k, v in vars(self).items() if not k.startswith("_"))
    result.update(
        exception_type=text_type(type(self)),
        exception_name=self.__class__.__name__,
        message=text_type(self),
        error=repr(self),
        caused_by=repr(self._caused_by),
        **self._kwargs,
    )
    return result
# Buggy code
def _finalize(self, commands, ext):
    commands = concatv(commands, ("",))  # add terminating newline
    if ext is None:
        return self.command_join.join(commands)
    elif ext:
        with NamedTemporaryFile("w+b", suffix=ext, delete=False) as tf:
            # the default mode is 'w+b', and universal new lines don't work in that mode
            # command_join should account for that
            tf.write(ensure_binary(self.command_join.join(commands)))
        return tf.name
    else:
        raise NotImplementedError()


# Traceback (ValueError)
$ source ~/anaconda/bin/activate
Traceback (most recent call last):
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 458
Logged from file exceptions.py, line 770
$ echo $ZSH_VERSION
5.3.1

# Fixed code
def _finalize(self, commands, ext):
    commands = concatv(commands, ("",))  # add terminating newline
    if ext is None:
        output = self.command_join.join(commands)
        if PY2:
            return ensure_binary(output)
        return output
    elif ext:
        with NamedTemporaryFile("w+b", suffix=ext, delete=False) as tf:
            # the default mode is 'w+b', and universal new lines don't work in that mode
            # command_join should account for that
            tf.write(ensure_binary(self.command_join.join(commands)))
        return tf.name
    else:
        raise NotImplementedError()
# Buggy code
def stdout_json(d):
    import json
    from .._vendor.auxlib.entity import EntityEncoder

    json.dump(d, sys.stdout, indent=2, sort_keys=True, cls=EntityEncoder)
    sys.stdout.write("\n")


# Traceback (ValueError)
$ source ~/anaconda/bin/activate
Traceback (most recent call last):
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 458
Logged from file exceptions.py, line 770
$ echo $ZSH_VERSION
5.3.1

# Fixed code
def stdout_json(d):
    print(json_dump(d))
# Buggy code
def main(*args):
    if not args:
        args = sys.argv

    args = tuple(_ensure_text_type(s) for s in args)

    if len(args) > 1:
        try:
            argv1 = args[1].strip()
            if argv1.startswith("shell."):
                from ..activate import main as activator_main

                return activator_main()
            elif argv1.startswith(".."):
                import conda.cli.activate as activate

                activate.main()
                return
            elif argv1 in ("activate", "deactivate"):
                from ..exceptions import CommandNotFoundError

                raise CommandNotFoundError(argv1)
        except Exception as e:
            _, exc_val, exc_tb = sys.exc_info()
            init_loggers()
            from ..exceptions import ExceptionHandler

            return ExceptionHandler().handle_exception(exc_val, exc_tb)

    from ..exceptions import conda_exception_handler

    return conda_exception_handler(_main, *args)


# Traceback (ValueError)
$ source ~/anaconda/bin/activate
Traceback (most recent call last):
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 458
Logged from file exceptions.py, line 770
$ echo $ZSH_VERSION
5.3.1

# Fixed code
def main(*args):
    # conda.common.compat contains only stdlib imports
    from ..common.compat import ensure_text_type  # , init_std_stream_encoding

    # init_std_stream_encoding()
    if not args:
        args = sys.argv

    args = tuple(ensure_text_type(s) for s in args)

    if len(args) > 1:
        try:
            argv1 = args[1].strip()
            if argv1.startswith("shell."):
                from ..activate import main as activator_main

                return activator_main()
            elif argv1.startswith(".."):
                import conda.cli.activate as activate

                activate.main()
                return
            elif argv1 in ("activate", "deactivate"):
                from ..exceptions import CommandNotFoundError

                raise CommandNotFoundError(argv1)
        except Exception as e:
            _, exc_val, exc_tb = sys.exc_info()
            init_loggers()
            from ..exceptions import ExceptionHandler

            return ExceptionHandler().handle_exception(exc_val, exc_tb)

    from ..exceptions import conda_exception_handler

    return conda_exception_handler(_main, *args)
# Buggy code
def json_dump(object):
    return json.dumps(
        object, indent=2, sort_keys=True, separators=(",", ": "), cls=EntityEncoder
    )


# Traceback (ValueError)
$ source ~/anaconda/bin/activate
Traceback (most recent call last):
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/home/ondrej/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/home/ondrej/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 458
Logged from file exceptions.py, line 770
$ echo $ZSH_VERSION
5.3.1

# Fixed code
def json_dump(object):
    return ensure_text_type(
        json.dumps(
            object, indent=2, sort_keys=True, separators=(",", ": "), cls=EntityEncoder
        )
    )
# Buggy code
def list_parameters(self):
    UNLISTED_PARAMETERS = (
        "bld_path",
        "conda_build",
        "croot",
        "debug",
        "default_python",
        "dry_run",
        "enable_private_envs",
        "error_upload_url",  # should remain undocumented
        "force_32bit",
        "ignore_pinned",
        "max_shlvl",
        "migrated_custom_channels",
        "only_dependencies",
        "prune",
        "root_prefix",
        "subdir",
        "subdirs",
        # https://conda.io/docs/config.html#disable-updating-of-dependencies-update-dependencies # NOQA
        # I don't think this documentation is correct any longer. # NOQA
        "target_prefix_override",  # used to override prefix rewriting, for e.g. building docker containers or RPMs  # NOQA
        "update_dependencies",
        "use_local",
    )
    return tuple(
        p
        for p in super(Context, self).list_parameters()
        if p not in UNLISTED_PARAMETERS
    )


# Traceback (ModuleNotFoundError)
% conda create -n no-ipython humidity -c davidmertz -y  # Silly example package
[... creating ...]
% conda activate no-ipython
(no-ipython) % ipython
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import humidity
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-5cdf29aced62> in <module>()
----> 1 import humidity
ModuleNotFoundError: No module named 'humidity'
In [2]:
Do you really want to exit ([y]/n)? y
(no-ipython) % which ipython
/Users/dmertz/anaconda3/bin/ipython
(no-ipython) % conda install ipython -y
[... installing ...]
(no-ipython) % which ipython
/Users/dmertz/anaconda3/envs/no-ipython/bin/ipython
(no-ipython) % ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import humidity
In [2]:

# Fixed code
def list_parameters(self):
    UNLISTED_PARAMETERS = (
        "bld_path",
        "conda_build",
        "croot",
        "debug",
        "default_python",
        "dry_run",
        "enable_private_envs",
        "error_upload_url",  # should remain undocumented
        "force_32bit",
        "ignore_pinned",
        "migrated_custom_channels",
        "only_dependencies",
        "prune",
        "root_prefix",
        "subdir",
        "subdirs",
        # https://conda.io/docs/config.html#disable-updating-of-dependencies-update-dependencies # NOQA
        # I don't think this documentation is correct any longer. # NOQA
        "target_prefix_override",  # used to override prefix rewriting, for e.g. building docker containers or RPMs  # NOQA
        "update_dependencies",
        "use_local",
    )
    return tuple(
        p
        for p in super(Context, self).list_parameters()
        if p not in UNLISTED_PARAMETERS
    )
# Buggy code
def __init__(self, enable_spin=True):
    self._stop_running = Event()
    self._spinner_thread = Thread(target=self._start_spinning)
    self._indicator_length = len(next(self.spinner_cycle)) + 1
    self.fh = sys.stdout
    self.show_spin = enable_spin and hasattr(self.fh, "isatty") and self.fh.isatty()


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def __init__(self, message, enabled=True, json=False):
    self.message = message
    self.enabled = enabled
    self.json = json

    self._stop_running = Event()
    self._spinner_thread = Thread(target=self._start_spinning)
    self._indicator_length = len(next(self.spinner_cycle)) + 1
    self.fh = sys.stdout
    self.show_spin = (
        enabled and not json and hasattr(self.fh, "isatty") and self.fh.isatty()
    )
# Buggy code
def start(self):
    if self.show_spin:
        self._spinner_thread.start()
    else:
        self.fh.write("...working... ")
        self.fh.flush()


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def start(self):
    if self.show_spin:
        self._spinner_thread.start()
    elif not self.json:
        self.fh.write("...working... ")
        self.fh.flush()
# Buggy code
def stop(self):
    if self.show_spin:
        self._stop_running.set()
        self._spinner_thread.join()


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def stop(self):
    if self.show_spin:
        self._stop_running.set()
        self._spinner_thread.join()
        self.show_spin = False
# Buggy code
def _start_spinning(self):
    while not self._stop_running.is_set():
        self.fh.write(next(self.spinner_cycle) + " ")
        self.fh.flush()
        sleep(0.10)
        self.fh.write("\b" * self._indicator_length)


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def _start_spinning(self):
    try:
        while not self._stop_running.is_set():
            self.fh.write(next(self.spinner_cycle) + " ")
            self.fh.flush()
            sleep(0.10)
            self.fh.write("\b" * self._indicator_length)
    except EnvironmentError as e:
        if e.errno in (EPIPE, ESHUTDOWN):
            self.stop()
        else:
            raise
# Buggy code
def update_to(self, fraction):
    if self.json:
        sys.stdout.write(
            '{"fetch":"%s","finished":false,"maxval":1,"progress":%f}\n\0'
            % (self.description, fraction)
        )
    elif self.enabled:
        self.pbar.update(fraction - self.pbar.n)


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def update_to(self, fraction):
    try:
        if self.json and self.enabled:
            sys.stdout.write(
                '{"fetch":"%s","finished":false,"maxval":1,"progress":%f}\n\0'
                % (self.description, fraction)
            )
        elif self.enabled:
            self.pbar.update(fraction - self.pbar.n)
    except EnvironmentError as e:
        if e.errno in (EPIPE, ESHUTDOWN):
            self.enabled = False
        else:
            raise
# Buggy code
def close(self):
    try:
        if self.json:
            sys.stdout.write(
                '{"fetch":"%s","finished":true,"maxval":1,"progress":1}\n\0'
                % self.description
            )
            sys.stdout.flush()
        elif self.enabled:
            self.pbar.close()
    except (IOError, OSError) as e:
        # Ignore BrokenPipeError and errors related to stdout or stderr being
        # closed by a downstream program.
        if e.errno not in (EPIPE, ESHUTDOWN):
            raise
    self.enabled = False


# Traceback (BrokenPipeError)
error: BrokenPipeError(32, 'Broken pipe')
command: /home/ubuntu/anaconda3/envs/tensorflow_p36/bin/conda install -p /home/ubuntu/anaconda3/envs/tensorflow_p36 tensorflow-gpu -y
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-1044-aws ubuntu/16.04 glibc/2.23
_messageid: -9223372036845075603
_messagetime: 1514219033248 / 2017-12-25 10:23:53

Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 724, in __call__
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 255, in install
handle_txn(progressive_fetch_extract, unlink_link_transaction, prefix, args, newenv)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/cli/install.py", line 281, in handle_txn
progressive_fetch_extract.execute()
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 575, in execute
exc = self._execute_actions(prec_or_spec, prec_actions)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/core/package_cache.py", line 590, in _execute_actions
progress_bar = ProgressBar(desc, not context.verbosity and not context.quiet, context.json)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/common/io.py", line 365, in __init__
self.pbar = tqdm(desc=description, bar_format=bar_format, ascii=True, total=1)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 767, in __init__
self.postfix, unit_divisor))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 201, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/conda/_vendor/tqdm/_tqdm.py", line 195, in fp_write
fp_flush()
BrokenPipeError: [Errno 32] Broken pipe

# Fixed code
def close(self):
    if self.enabled and self.json:
        sys.stdout.write(
            '{"fetch":"%s","finished":true,"maxval":1,"progress":1}\n\0'
            % self.description
        )
        sys.stdout.flush()
    elif self.enabled:
        self.pbar.close()
# Buggy code
def build_reactivate(self):
    conda_prefix = os.environ.get("CONDA_PREFIX")
    conda_shlvl = int(os.environ.get("CONDA_SHLVL", -1))
    if not conda_prefix or conda_shlvl < 1:
        # no active environment, so cannot reactivate; do nothing
        return {
            "unset_vars": (),
            "set_vars": {},
            "export_vars": {},
            "deactivate_scripts": (),
            "activate_scripts": (),
        }
    conda_default_env = os.environ.get(
        "CONDA_DEFAULT_ENV", self._default_env(conda_prefix)
    )
    # environment variables are set only to aid transition from conda 4.3 to conda 4.4
    return {
        "unset_vars": (),
        "set_vars": {},
        "export_vars": {
            "CONDA_SHLVL": conda_shlvl,
            "CONDA_PROMPT_MODIFIER": self._prompt_modifier(conda_default_env),
        },
        "deactivate_scripts": self._get_deactivate_scripts(conda_prefix),
        "activate_scripts": self._get_activate_scripts(conda_prefix),
    }


# Traceback (ValueError)
Traceback (most recent call last):
File "/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 513
Logged from file exceptions.py, line 724

# Fixed code
def build_reactivate(self):
    conda_prefix = self.environ.get("CONDA_PREFIX")
    conda_shlvl = int(self.environ.get("CONDA_SHLVL", -1))
    if not conda_prefix or conda_shlvl < 1:
        # no active environment, so cannot reactivate; do nothing
        return {
            "unset_vars": (),
            "set_vars": {},
            "export_vars": {},
            "deactivate_scripts": (),
            "activate_scripts": (),
        }
    conda_default_env = self.environ.get(
        "CONDA_DEFAULT_ENV", self._default_env(conda_prefix)
    )
    # environment variables are set only to aid transition from conda 4.3 to conda 4.4
    return {
        "unset_vars": (),
        "set_vars": {},
        "export_vars": {
            "CONDA_SHLVL": conda_shlvl,
            "CONDA_PROMPT_MODIFIER": self._prompt_modifier(conda_default_env),
        },
        "deactivate_scripts": self._get_deactivate_scripts(conda_prefix),
        "activate_scripts": self._get_activate_scripts(conda_prefix),
    }
# Buggy code
def _update_prompt(self, set_vars, conda_prompt_modifier):
    if not context.changeps1:
        return

    if self.shell == "posix":
        ps1 = os.environ.get("PS1", "")
        current_prompt_modifier = os.environ.get("CONDA_PROMPT_MODIFIER")
        if current_prompt_modifier:
            ps1 = re.sub(re.escape(current_prompt_modifier), r"", ps1)
        # Because we're using single-quotes to set shell variables, we need to handle the
        # proper escaping of single quotes that are already part of the string.
        # Best solution appears to be https://stackoverflow.com/a/1250279
        ps1 = ps1.replace("'", "'\"'\"'")
        set_vars.update(
            {
                "PS1": conda_prompt_modifier + ps1,
            }
        )
    elif self.shell == "csh":
        prompt = os.environ.get("prompt", "")
        current_prompt_modifier = os.environ.get("CONDA_PROMPT_MODIFIER")
        if current_prompt_modifier:
            prompt = re.sub(re.escape(current_prompt_modifier), r"", prompt)
        set_vars.update(
            {
                "prompt": conda_prompt_modifier + prompt,
            }
        )


# Traceback (ValueError)
Traceback (most recent call last):
File "/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 513
Logged from file exceptions.py, line 724

# Fixed code
def _update_prompt(self, set_vars, conda_prompt_modifier):
    if not context.changeps1:
        return

    if self.shell == "posix":
        ps1 = self.environ.get("PS1", "")
        current_prompt_modifier = self.environ.get("CONDA_PROMPT_MODIFIER")
        if current_prompt_modifier:
            ps1 = re.sub(re.escape(current_prompt_modifier), r"", ps1)
        # Because we're using single-quotes to set shell variables, we need to handle the
        # proper escaping of single quotes that are already part of the string.
        # Best solution appears to be https://stackoverflow.com/a/1250279
        ps1 = ps1.replace("'", "'\"'\"'")
        set_vars.update(
            {
                "PS1": conda_prompt_modifier + ps1,
            }
        )
    elif self.shell == "csh":
        prompt = self.environ.get("prompt", "")
        current_prompt_modifier = self.environ.get("CONDA_PROMPT_MODIFIER")
        if current_prompt_modifier:
            prompt = re.sub(re.escape(current_prompt_modifier), r"", prompt)
        set_vars.update(
            {
                "prompt": conda_prompt_modifier + prompt,
            }
        )
# Buggy code
def __enter__(self):
    enabled = os.environ.get("CONDA_INSTRUMENTATION_ENABLED")
    if enabled and boolify(enabled):
        self.start_time = time()


# Traceback (RuntimeError)
error: RuntimeError("generator didn't stop after throw()",)
command: /home/mholekev/miniconda3/bin/conda install --yes numpy scipy matplotlib jupyter git pandas
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/2.6.32-696.10.3.el6.x86_64 centos/6.7 glibc/2.12
_messageid: -9223372036842075552
_messagetime: 1514766990662 / 2017-12-31 18:36:30

Traceback (most recent call last):
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/common/io.py", line 399, in backdown_thread_pool
yield ThreadPoolExecutor(max_workers)
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 214, in get_reduced_index
new_records = query_all(spec)
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 187, in query_all
return tuple(concat(future.result() for future in as_completed(futures)))
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 187, in <genexpr>
return tuple(concat(future.result() for future in as_completed(futures)))
File "/home/mholekev/miniconda3/lib/python3.6/concurrent/futures/_base.py", line 217, in as_completed
fs = set(fs)
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 186, in <genexpr>
futures = (executor.submit(sd.query, spec) for sd in subdir_datas)
File "/home/mholekev/miniconda3/lib/python3.6/concurrent/futures/thread.py", line 123, in submit
self._adjust_thread_count()
File "/home/mholekev/miniconda3/lib/python3.6/concurrent/futures/thread.py", line 142, in _adjust_thread_count
t.start()
File "/home/mholekev/miniconda3/lib/python3.6/threading.py", line 846, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

# Fixed code
def __enter__(self):
    enabled = os.environ.get("CONDA_INSTRUMENTATION_ENABLED")
    if enabled and boolify(enabled):
        self.start_time = time()
    return self
# Buggy code
def query_all(channels, subdirs, package_ref_or_match_spec):
    channel_urls = all_channel_urls(channels, subdirs=subdirs)

    executor = None
    try:
        from concurrent.futures import ThreadPoolExecutor, as_completed

        executor = ThreadPoolExecutor(10)
        futures = (
            executor.submit(SubdirData(Channel(url)).query, package_ref_or_match_spec)
            for url in channel_urls
        )
        return tuple(concat(future.result() for future in as_completed(futures)))
    except RuntimeError as e:  # pragma: no cover
        # concurrent.futures is only available in Python >= 3.2 or if futures is installed
        # RuntimeError is thrown if number of threads are limited by OS
        raise
    finally:
        if executor:
            executor.shutdown(wait=True)


# Traceback (RuntimeError)
error: RuntimeError("generator didn't stop after throw()",)
command: /home/mholekev/miniconda3/bin/conda install --yes numpy scipy matplotlib jupyter git pandas
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Linux/2.6.32-696.10.3.el6.x86_64 centos/6.7 glibc/2.12
_messageid: -9223372036842075552
_messagetime: 1514766990662 / 2017-12-31 18:36:30

Traceback (most recent call last):
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/common/io.py", line 399, in backdown_thread_pool
yield ThreadPoolExecutor(max_workers)
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 214, in get_reduced_index
new_records = query_all(spec)
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 187, in query_all
return tuple(concat(future.result() for future in as_completed(futures)))
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 187, in <genexpr>
return tuple(concat(future.result() for future in as_completed(futures)))
File "/home/mholekev/miniconda3/lib/python3.6/concurrent/futures/_base.py", line 217, in as_completed
fs = set(fs)
File "/home/mholekev/miniconda3/lib/python3.6/site-packages/conda/core/index.py", line 186, in <genexpr>
futures = (executor.submit(sd.query, spec) for sd in subdir_datas)
File "/home/mholekev/miniconda3/lib/python3.6/concurrent/futures/thread.py", line 123, in submit
self._adjust_thread_count()
File "/home/mholekev/miniconda3/lib/python3.6/concurrent/futures/thread.py", line 142, in _adjust_thread_count
t.start()
File "/home/mholekev/miniconda3/lib/python3.6/threading.py", line 846, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread

# Fixed code
def query_all(channels, subdirs, package_ref_or_match_spec):
    from .index import check_whitelist  # TODO: fix in-line import

    channel_urls = all_channel_urls(channels, subdirs=subdirs)
    check_whitelist(channel_urls)
    with ThreadLimitedThreadPoolExecutor() as executor:
        futures = (
            executor.submit(SubdirData(Channel(url)).query, package_ref_or_match_spec)
            for url in channel_urls
        )
        return tuple(concat(future.result() for future in as_completed(futures)))
# Buggy code
def _load_single_record(self, prefix_record_json_path):
    log.trace("loading prefix record %s", prefix_record_json_path)
    with open(prefix_record_json_path) as fh:
        json_data = json_load(fh.read())
    prefix_record = PrefixRecord(**json_data)
    self.__prefix_records[prefix_record.name] = prefix_record


# Traceback (json.decoder.JSONDecodeError)
Traceback (most recent call last):
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/exceptions.py", line 640, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/cli/main.py", line 140, in _main
exit_code = args.func(args, p)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/cli/main_list.py", line 242, in execute
show_channel_urls=context.show_channel_urls)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/cli/main_list.py", line 172, in print_packages
installed = linked(prefix)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/core/linked_data.py", line 123, in linked
return set(linked_data(prefix, ignore_channels=ignore_channels).keys())
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/core/linked_data.py", line 115, in linked_data
load_linked_data(prefix, dist_name, ignore_channels=ignore_channels)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/site-packages/conda/core/linked_data.py", line 36, in load_linked_data
rec = json.load(fi)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/json/__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/dhj/anaconda3-5.0.1/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

# Fixed code
def _load_single_record(self, prefix_record_json_path):
    log.trace("loading prefix record %s", prefix_record_json_path)
    with open(prefix_record_json_path) as fh:
        try:
            json_data = json_load(fh.read())
        except JSONDecodeError:
            raise CorruptedEnvironmentError(self.prefix_path, prefix_record_json_path)

    prefix_record = PrefixRecord(**json_data)
    self.__prefix_records[prefix_record.name] = prefix_record
# Buggy code
def main(argv=None):
    argv = argv or sys.argv
    assert len(argv) >= 3
    assert argv[1].startswith("shell.")
    shell = argv[1].replace("shell.", "", 1)
    activator_args = argv[2:]
    activator = Activator(shell, activator_args)
    try:
        sys.stdout.write(activator.execute())
        return 0
    except Exception as e:
        from . import CondaError

        if isinstance(e, CondaError):
            sys.stderr.write(text_type(e))
            return e.return_code
        else:
            raise


# Traceback (KeyError)
error: KeyError(u'CONDA_PREFIX',)
command: D:\Anaconda2\Scripts\conda shell.cmd.exe deactivate deactivate
user_agent: conda/4.4.4 requests/2.18.4 CPython/2.7.14 Windows/10 Windows/10.0.16299
_messageid: -9223372036842425555
_messagetime: 1514685063692 / 2017-12-30 19:51:03

Traceback (most recent call last):
File "D:\Anaconda2\lib\site-packages\conda\cli\main.py", line 111, in main
return activator_main()
File "D:\Anaconda2\lib\site-packages\conda\activate.py", line 529, in main
sys.stdout.write(activator.execute())
File "D:\Anaconda2\lib\site-packages\conda\activate.py", line 149, in execute
return getattr(self, self.command)()
File "D:\Anaconda2\lib\site-packages\conda\activate.py", line 139, in deactivate
return self._finalize(self._yield_commands(self.build_deactivate()),
File "D:\Anaconda2\lib\site-packages\conda\activate.py", line 288, in build_deactivate
old_conda_prefix = os.environ['CONDA_PREFIX']
File "D:\Anaconda2\lib\os.py", line 425, in __getitem__
return self.data[key.upper()]
KeyError: u'CONDA_PREFIX'

# Fixed code
def main(argv=None):
    argv = argv or sys.argv
    assert len(argv) >= 3
    assert argv[1].startswith("shell.")
    shell = argv[1].replace("shell.", "", 1)
    activator_args = argv[2:]
    activator = Activator(shell, activator_args)
    try:
        print(activator.execute(), end="")
        return 0
    except Exception as e:
        from . import CondaError

        if isinstance(e, CondaError):
            print(text_type(e), file=sys.stderr)
            return e.return_code
        else:
            raise