# Buggy code
def solve_for_transaction(
    self,
    deps_modifier=NULL,
    prune=NULL,
    ignore_pinned=NULL,
    force_remove=NULL,
    force_reinstall=False,
):
    """Gives an UnlinkLinkTransaction instance that can be used to execute the solution
    on an environment.

    Args:
        deps_modifier (DepsModifier):
            See :meth:`solve_final_state`.
        prune (bool):
            See :meth:`solve_final_state`.
        ignore_pinned (bool):
            See :meth:`solve_final_state`.
        force_remove (bool):
            See :meth:`solve_final_state`.
        force_reinstall (bool):
            See :meth:`solve_for_diff`.

    Returns:
        UnlinkLinkTransaction:

    """
    with spinner(
        "Solving environment", not context.verbosity and not context.quiet, context.json
    ):
        if self.prefix == context.root_prefix and context.enable_private_envs:
            # This path has the ability to generate a multi-prefix transaction. The basic logic
            # is in the commented out get_install_transaction() function below. Exercised at
            # the integration level in the PrivateEnvIntegrationTests in test_create.py.
            raise NotImplementedError()
        else:
            unlink_precs, link_precs = self.solve_for_diff(
                deps_modifier, prune, ignore_pinned, force_remove, force_reinstall
            )
            stp = PrefixSetup(
                self.prefix,
                unlink_precs,
                link_precs,
                self.specs_to_remove,
                self.specs_to_add,
            )
            # TODO: Only explicitly requested remove and update specs are being included in
            #   History right now. Do we need to include other categories from the solve?

    if context.notify_outdated_conda:
        conda_newer_spec = MatchSpec("conda >%s" % CONDA_VERSION)
        if not any(conda_newer_spec.match(prec) for prec in link_precs):
            conda_newer_records = sorted(
                SubdirData.query_all(self.channels, self.subdirs, conda_newer_spec),
                key=lambda x: VersionOrder(x.version),
            )
            if conda_newer_records:
                latest_version = conda_newer_records[-1].version
                sys.stderr.write(
                    dedent("""

                    ==> WARNING: A newer version of conda exists. <==
                      current version: %s
                      latest version: %s

                    Please update conda by running

                        $ conda update -n base conda


                    """)
                    % (CONDA_VERSION, latest_version)
                )

    return UnlinkLinkTransaction(stp)


# 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 solve_for_transaction(
    self,
    deps_modifier=NULL,
    prune=NULL,
    ignore_pinned=NULL,
    force_remove=NULL,
    force_reinstall=False,
):
    """Gives an UnlinkLinkTransaction instance that can be used to execute the solution
    on an environment.

    Args:
        deps_modifier (DepsModifier):
            See :meth:`solve_final_state`.
        prune (bool):
            See :meth:`solve_final_state`.
        ignore_pinned (bool):
            See :meth:`solve_final_state`.
        force_remove (bool):
            See :meth:`solve_final_state`.
        force_reinstall (bool):
            See :meth:`solve_for_diff`.

    Returns:
        UnlinkLinkTransaction:

    """
    with Spinner(
        "Solving environment", not context.verbosity and not context.quiet, context.json
    ):
        if self.prefix == context.root_prefix and context.enable_private_envs:
            # This path has the ability to generate a multi-prefix transaction. The basic logic
            # is in the commented out get_install_transaction() function below. Exercised at
            # the integration level in the PrivateEnvIntegrationTests in test_create.py.
            raise NotImplementedError()
        else:
            unlink_precs, link_precs = self.solve_for_diff(
                deps_modifier, prune, ignore_pinned, force_remove, force_reinstall
            )
            stp = PrefixSetup(
                self.prefix,
                unlink_precs,
                link_precs,
                self.specs_to_remove,
                self.specs_to_add,
            )
            # TODO: Only explicitly requested remove and update specs are being included in
            #   History right now. Do we need to include other categories from the solve?

    if context.notify_outdated_conda:
        conda_newer_spec = MatchSpec("conda >%s" % CONDA_VERSION)
        if not any(conda_newer_spec.match(prec) for prec in link_precs):
            conda_newer_records = sorted(
                SubdirData.query_all(self.channels, self.subdirs, conda_newer_spec),
                key=lambda x: VersionOrder(x.version),
            )
            if conda_newer_records:
                latest_version = conda_newer_records[-1].version
                print(
                    dedent("""

                    ==> WARNING: A newer version of conda exists. <==
                      current version: %s
                      latest version: %s

                    Please update conda by running

                        $ conda update -n base conda

                    """)
                    % (CONDA_VERSION, latest_version),
                    file=sys.stderr,
                )

    return UnlinkLinkTransaction(stp)