internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: conda/conda

Issue:
setting default_channels from CLI raises NotImplementedError



Discussion:

Resolving patch:
diff --git a/conda/cli/main_config.py b/conda/cli/main_config.py
--- a/conda/cli/main_config.py
+++ b/conda/cli/main_config.py
@@ -377,9 +377,6 @@ def execute_config(args, parser):
                 bad = rc_config[key].__class__.__name__
                 from ..exceptions import CouldntParseError
                 raise CouldntParseError("key %r should be a list, not %s." % (key, bad))
-            if key == 'default_channels' and rc_path != sys_rc_path:
-                msg = "'default_channels' is only configurable for system installs"
-                raise NotImplementedError(msg)
             arglist = rc_config.setdefault(key, [])
             if item in arglist:
                 # Right now, all list keys should not contain duplicates


Test patch:
Repository: conda/conda

Issue:
Purging the ".trash" folder.
OS: Windows.

When updating an environment, a snapshot of the environment get stored in the ```[miniconda]\pkgs\.trash```

Is there a way to clean up this trash directory with a ```conda``` command?


Discussion:
I also have this problem and would be interested in a solution. My reading of the code is that a call to `delete_trash()` needs to be added somewhere, but I'm not sufficiently familiar with the code to know the best way to do this.
Further to this, if you try to manually delete the environment snapshots, you'll get a "Access denied" error if the environment is in use.
The `.trash` directory is what we've resorted to for dealing with windows file locking.  This is really a Windows OS issue.  Windows aggressively locks files on a per-process basis, which means if a process is "using" a file, conda won't be able to delete it.  We can rename it however, and move it to the .trash directory.

The `delete_trash()` function is called at the end of `create`, `install`, `update`, and `remove` operations.  See:

* https://github.com/conda/conda/blob/4.3.x/conda/cli/main_create.py#L69
* https://github.com/conda/conda/blob/4.3.x/conda/cli/main_install.py#L81
* https://github.com/conda/conda/blob/4.3.x/conda/cli/main_update.py#L66
* https://github.com/conda/conda/blob/4.3.x/conda/cli/main_remove.py#L172

Maybe we could get a ```delete_trash()``` when dealing with environments?

https://github.com/conda/conda/blob/4.3.x/conda_env/cli/main_create.py
Yeah good idea. 

Sent from my iPhone

> On Sep 29, 2017, at 2:11 AM, Toke Jepsen <notifications@github.com> wrote:
> 
> Maybe we could get a delete_trash() when dealing with environments?
> 
> https://github.com/conda/conda/blob/4.3.x/conda_env/cli/main_create.py
> 
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 


Resolving patch:
diff --git a/conda_env/cli/main_create.py b/conda_env/cli/main_create.py
--- a/conda_env/cli/main_create.py
+++ b/conda_env/cli/main_create.py
@@ -6,7 +6,7 @@
 import textwrap
 
 from conda.cli import common, install as cli_install
-from conda.gateways.disk.delete import rm_rf
+from conda.gateways.disk.delete import rm_rf, delete_trash
 from conda.misc import touch_nonadmin
 from conda.plan import is_root_prefix
 
@@ -119,5 +119,6 @@ def execute(args, parser):
             return -1
 
     touch_nonadmin(prefix)
+    delete_trash()
     if not args.json:
         print(cli_install.print_activate(args.name if args.name else prefix))


Test patch:
Repository: conda/conda

Issue:
conda 4.4.0rc2 AttributeError on 'conda remove'
    "command": "/home/matt/anaconda3/bin/conda remove --name tensorflow"

```
AttributeError", "exception_type": "<class 'AttributeError'>", "traceback": "Traceback (most recent call last):
  File \"/home/matt/anaconda3/lib/python3.6/site-packages/conda/exceptions.py\", line 683, in __call__
    return func(*args, **kwargs)
  File \"/home/matt/anaconda3/lib/python3.6/site-packages/conda/cli/main.py\", line 78, in _main
    exit_code = do_call(args, p)
  File \"/home/matt/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/matt/anaconda3/lib/python3.6/site-packages/conda/cli/main_remove.py\", line 28, in execute
    if not (args.all or args.package_names or args.features):
AttributeError: 'Namespace' object has no attribute 'features'
```


Discussion:

Resolving patch:
diff --git a/conda/cli/main_remove.py b/conda/cli/main_remove.py
--- a/conda/cli/main_remove.py
+++ b/conda/cli/main_remove.py
@@ -25,7 +25,7 @@
 
 def execute(args, parser):
 
-    if not (args.all or args.package_names or args.features):
+    if not (args.all or args.package_names):
         raise CondaValueError('no package names supplied,\n'
                               '       try "conda remove -h" for more details')
 


Test patch:
Repository: conda/conda

Issue:
conda 4.4.0rc2 NotImplementedError on 'conda list'
    "command": "/home/rob/miniconda3/bin/conda list"

```
Traceback (most recent call last):
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/exceptions.py\", line 683, in __call__
    return func(*args, **kwargs)
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/cli/main.py\", line 78, in _main
    exit_code = do_call(args, p)
  File \"/home/rob/miniconda3/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/rob/miniconda3/lib/python3.6/site-packages/conda/cli/main_list.py\", line 150, in execute
    show_channel_urls=context.show_channel_urls)
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/cli/main_list.py\", line 90, in print_packages
    show_channel_urls=show_channel_urls)
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/cli/main_list.py\", line 52, in list_packages
    info = is_linked(prefix, dist)
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/core/linked_data.py\", line 166, in is_linked
    elif MatchSpec(dist).match(prefix_record):
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/models/match_spec.py\", line 67, in __call__
    return super(MatchSpecType, cls).__call__(**parsed)
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/models/match_spec.py\", line 178, in __init__
    self._match_components = self._build_components(**kwargs)
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/models/match_spec.py\", line 359, in _build_components
    return frozendict(_make(key, value) for key, value in iteritems(kwargs))
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/models/match_spec.py\", line 359, in <genexpr>
    return frozendict(_make(key, value) for key, value in iteritems(kwargs))
  File \"/home/rob/miniconda3/lib/python3.6/site-packages/conda/models/match_spec.py\", line 355, in _make
    raise NotImplementedError()
NotImplementedError

```


Discussion:

Resolving patch:
diff --git a/conda/models/match_spec.py b/conda/models/match_spec.py
--- a/conda/models/match_spec.py
+++ b/conda/models/match_spec.py
@@ -349,10 +349,8 @@ def _make(field_name, value):
                 matcher = value
             elif field_name in _implementors:
                 matcher = _implementors[field_name](value)
-            elif text_type(value):
-                matcher = StrMatch(value)
             else:
-                raise NotImplementedError()
+                matcher = StrMatch(text_type(value))
 
             return field_name, matcher
 


Test patch:
Repository: conda/conda

Issue:
conda 4.4 rc2: failure in conda list when editable install has been moved
`conda list` for my root environment is working nicely using conda 4.3, but when upgrading with canary to conda 4.4.0 rc2, the `conda list` command fails with the following error:

```
joris@joris-XPS-13-9350:~/scipy$ conda list
# packages in environment at /home/joris/miniconda3:
#

`$ /home/joris/miniconda3/bin/conda list`

    Traceback (most recent call last):
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/exceptions.py", line 683, in __call__
        return func(*args, **kwargs)
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/cli/main.py", line 78, in _main
        exit_code = do_call(args, p)
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/cli/conda_argparse.py", line 75, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/cli/main_list.py", line 150, in execute
        show_channel_urls=context.show_channel_urls)
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/cli/main_list.py", line 85, in print_packages
        other_python = get_egg_info(prefix)
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/egg_info.py", line 86, in get_egg_info
        for path in get_egg_info_files(join(prefix, sp_dir)):
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/egg_info.py", line 35, in get_egg_info_files
        for egg in get_egg_info_files(reader.readline().strip()):
      File "/home/joris/miniconda3/lib/python3.5/site-packages/conda/egg_info.py", line 32, in get_egg_info_files
        for fn in os.listdir(sp_dir):
    FileNotFoundError: [Errno 2] No such file or directory: '/home/joris/scipy/dateutil'
```

The reason for this is that I once did `pip install -e .` in the  '/home/joris/scipy/dateutil' directory to test out a dev install of dateutil. But later I removed it. Until now it was not a problem, but so now it is starting to give problems with conda 4.4. 
I know I can fix this by removing it manually from easy-install.pth, but IMO it could be handles more gracefully by conda.


Discussion:
.

Resolving patch:
diff --git a/conda/egg_info.py b/conda/egg_info.py
--- a/conda/egg_info.py
+++ b/conda/egg_info.py
@@ -75,7 +75,7 @@ def get_egg_info(prefix, all_pkgs=False):
     """
     installed_pkgs = linked_data(prefix)
     sp_dir = get_site_packages_dir(installed_pkgs)
-    if sp_dir is None:
+    if sp_dir is None or not isdir(join(prefix, sp_dir)):
         return set()
 
     conda_files = set()


Test patch:
Repository: conda/conda

Issue:
custom_channels incorrect in 'conda config --show'
Especially for anaconda channel, weird replacement happening.


Discussion:

Resolving patch:
diff --git a/conda/cli/main_config.py b/conda/cli/main_config.py
--- a/conda/cli/main_config.py
+++ b/conda/cli/main_config.py
@@ -17,7 +17,7 @@
 from .. import CondaError
 from ..base.constants import CONDA_HOMEPAGE_URL
 from ..base.context import context
-from ..common.compat import isiterable, iteritems, string_types, text_type
+from ..common.compat import isiterable, iteritems, itervalues, string_types, text_type
 from ..common.constants import NULL
 from ..config import (rc_bool_keys, rc_list_keys, rc_other, rc_string_keys, sys_rc_path,
                       user_rc_path)
@@ -264,8 +264,10 @@ def execute_config(args, parser):
                   cls=EntityEncoder))
         else:
             # coerce channels
-            d['custom_channels'] = {k: text_type(v).replace(k, '')  # TODO: the replace here isn't quite right  # NOQA
-                                    for k, v in iteritems(d['custom_channels'])}
+            d['custom_channels'] = {
+                channel.name: "%s://%s" % (channel.scheme, channel.location)
+                for channel in itervalues(d['custom_channels'])
+            }
             # TODO: custom_multichannels needs better formatting
             d['custom_multichannels'] = {k: json.dumps([text_type(c) for c in chnls])
                                          for k, chnls in iteritems(d['custom_multichannels'])}


Test patch:
Repository: conda/conda

Issue:
TypeError: not all arguments converted during string formatting
    "command": "C:\\Users\\court\\Anaconda3\\Scripts\\conda install matplotlib"
    "user_agent": "conda/4.4.1 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.16299"

```
Traceback (most recent call last):
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\exceptions.py\", line 721, in __call__
    return func(*args, **kwargs)
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\cli\\main.py\", line 78, in _main
    exit_code = do_call(args, p)
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\cli\\conda_argparse.py\", line 75, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\cli\\main_install.py\", line 11, in execute
    install(args, parser, 'install')
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\cli\\install.py\", line 220, in install
    force_reinstall=context.force,
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\core\\solve.py\", line 503, in solve_for_transaction
    force_remove, force_reinstall)
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\core\\solve.py\", line 436, in solve_for_diff
    final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
  File \"C:\\Users\\court\\Anaconda3\\lib\\site-packages\\conda\\core\\solve.py\", line 244, in solve_final_state
    \"\"\") % matches_for_spec)
TypeError: not all arguments converted during string formatting
```


Discussion:

Resolving patch:
diff --git a/conda/core/solve.py b/conda/core/solve.py
--- a/conda/core/solve.py
+++ b/conda/core/solve.py
@@ -241,7 +241,7 @@ def solve_final_state(self, deps_modifier=NULL, prune=NULL, ignore_pinned=NULL,
                     the output of 'conda info' and 'conda list' for the active environment, along
                     with the command you invoked that resulted in this error.
                       matches_for_spec: %s
-                    """) % matches_for_spec)
+                    """) % dashlist((text_type(s) for s in matches_for_spec), indent=4))
                 target_dist = matches_for_spec[0]
                 if deps_modifier == DepsModifier.FREEZE_INSTALLED:
                     new_spec = MatchSpec(index[target_dist])


Test patch:
Repository: conda/conda

Issue:
python 2 can't read unicode in environments.txt
on a conda install operation, during the transaction

```
Traceback (most recent call last):
  File "/Users/kfranz/continuum/conda/conda/core/link.py", line 535, in _execute_actions
    action.execute()
  File "/Users/kfranz/continuum/conda/conda/core/path_actions.py", line 876, in execute
    register_env(self.target_prefix)
  File "/Users/kfranz/continuum/conda/conda/core/envs_manager.py", line 28, in register_env
    if location in yield_lines(USER_ENVIRONMENTS_TXT_FILE):
  File "/Users/kfranz/continuum/conda/conda/gateways/disk/read.py", line 49, in yield_lines
    if not line or line.startswith('#'):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 54: ordinal not in range(128)
```


Discussion:
Part of my `~/.conda/environments.txt` file that's causing python 2 to choke:

```
/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/envs/shapely=1.6.0
/var/folders/cp/7r2s_s593j7_cpdtxxsmct880000gp/T/26b3 çêôñáß
/var/folders/cp/7r2s_s593j7_cpdtxxsmct880000gp/T/8eba áçêßôñ
/Users/kfranz/miniconda/envs/py2
/conda3
/Users/kfranz/miniconda/envs/_test2
```

Resolving patch:
diff --git a/conda/core/envs_manager.py b/conda/core/envs_manager.py
--- a/conda/core/envs_manager.py
+++ b/conda/core/envs_manager.py
@@ -7,7 +7,7 @@
 
 from ..base.constants import ROOT_ENV_NAME
 from ..base.context import context
-from ..common.compat import on_win
+from ..common.compat import ensure_text_type, on_win, open
 from ..common.path import expand, paths_equal
 from ..gateways.disk.read import yield_lines
 from ..gateways.disk.test import is_conda_environment
@@ -30,7 +30,7 @@ def register_env(location):
         return
 
     with open(USER_ENVIRONMENTS_TXT_FILE, 'a') as fh:
-        fh.write(location)
+        fh.write(ensure_text_type(location))
         fh.write('\n')
 
 
diff --git a/conda/gateways/disk/read.py b/conda/gateways/disk/read.py
--- a/conda/gateways/disk/read.py
+++ b/conda/gateways/disk/read.py
@@ -19,7 +19,7 @@
 from ..._vendor.auxlib.collection import first
 from ..._vendor.auxlib.ish import dals
 from ...base.constants import PREFIX_PLACEHOLDER
-from ...common.compat import ensure_text_type
+from ...common.compat import ensure_text_type, open
 from ...exceptions import CondaUpgradeError, CondaVerificationError, PathNotFoundError
 from ...models.channel import Channel
 from ...models.enums import FileMode, PathType


Test patch:
Repository: conda/conda

Issue:
conda list FileNotFoundError
```
"command": "/Users/hideki/anaconda/bin/conda list"
"user_agent": "conda/4.4.3 requests/2.14.2 CPython/3.5.2 Darwin/16.7.0 OSX/10.12.6"

Traceback (most recent call last):
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/exceptions.py\", line 722, in __call__
    return func(*args, **kwargs)
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/cli/main.py\", line 78, in _main
    exit_code = do_call(args, p)
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/cli/conda_argparse.py\", line 75, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/cli/main_list.py\", line 150, in execute
    show_channel_urls=context.show_channel_urls)
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/cli/main_list.py\", line 85, in print_packages
    other_python = get_egg_info(prefix)
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/egg_info.py\", line 86, in get_egg_info
    for path in get_egg_info_files(join(prefix, sp_dir)):
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/egg_info.py\", line 35, in get_egg_info_files
    for egg in get_egg_info_files(reader.readline().strip()):
  File \"/Users/hideki/anaconda/lib/python3.5/site-packages/conda/egg_info.py\", line 32, in get_egg_info_files
    for fn in os.listdir(sp_dir):
FileNotFoundError: [Errno 2] No such file or directory: '/Users/hideki/darkflow'

```


Discussion:

Resolving patch:
diff --git a/conda/egg_info.py b/conda/egg_info.py
--- a/conda/egg_info.py
+++ b/conda/egg_info.py
@@ -29,7 +29,7 @@ def get_site_packages_dir(installed_pkgs):
 
 
 def get_egg_info_files(sp_dir):
-    for fn in os.listdir(sp_dir):
+    for fn in (isdir(sp_dir) and os.listdir(sp_dir) or ()):
         if fn.endswith('.egg-link'):
             with open(join(sp_dir, fn), 'r') as reader:
                 for egg in get_egg_info_files(reader.readline().strip()):


Test patch:
Repository: conda/conda

Issue:
conda env giving strange non-blocking behavior on Windows
Using conda 4.4.4, this is happening in both the Anaconda prompt and Git Bash. To reproduce, simply run `conda env -h`. The prompt will return and it seems like conda is run in the background, producing output a few seconds later. Strangely enough, this doesn't happen when running `conda-env -h`.


Discussion:
I noticed that too.  Is it new in 4.4, and not that way in 4.3?  I guess it's coming from using `os.execv()`, which apparently behaves differently on Windows than I'm used to on unix systems?
To clarify, I noticed it yesterday with `conda build`.
I never noticed this sort of thing with any older versions.
Oh, and I was working in `cmd.exe`, not git bash.  So it's I guess a problem universal to Windows.

Resolving patch:
diff --git a/conda/cli/conda_argparse.py b/conda/cli/conda_argparse.py
--- a/conda/cli/conda_argparse.py
+++ b/conda/cli/conda_argparse.py
@@ -6,6 +6,7 @@
 from logging import getLogger
 import os
 from os.path import abspath, expanduser, join
+from subprocess import Popen
 import sys
 from textwrap import dedent
 
@@ -133,8 +134,13 @@ def error(self, message):
                             from ..exceptions import CommandNotFoundError
                             raise CommandNotFoundError(cmd)
                         args = [find_executable('conda-' + cmd)]
-                        args.extend(sys.argv[2:])
-                        os.execv(args[0], args)
+                        p = Popen(args)
+                        try:
+                            p.communicate()
+                        except KeyboardInterrupt:
+                            p.wait()
+                        finally:
+                            sys.exit(p.returncode)
 
         super(ArgumentParser, self).error(message)
 


Test patch:
Repository: conda/conda

Issue:
version '==' interpreted differently in 4.3 and 4.4



Discussion:

Resolving patch:
diff --git a/conda/models/version.py b/conda/models/version.py
--- a/conda/models/version.py
+++ b/conda/models/version.py
@@ -463,12 +463,17 @@ def __new__(cls, spec):
             self.op = VersionOrder.startswith
             self.cmp = VersionOrder(spec.rstrip('*').rstrip('.'))
             self.match = self.veval_match_
+        elif '@' not in spec:
+            self.op = opdict["=="]
+            self.cmp = VersionOrder(spec)
+            self.match = self.veval_match_
         else:
             self.match = self.exact_match_
         return self
 
     def is_exact(self):
-        return self.match == self.exact_match_
+        return (self.match == self.exact_match_
+                or self.match == self.veval_match_ and self.op == op.__eq__)
 
     def __eq__(self, other):
         try:


Test patch:
diff --git a/tests/models/test_match_spec.py b/tests/models/test_match_spec.py
--- a/tests/models/test_match_spec.py
+++ b/tests/models/test_match_spec.py
@@ -50,6 +50,7 @@ def test_match_1(self):
             ('numpy >1.8,<2|==1.7', False),('numpy >1.8,<2|>=1.7.1', True),
             ('numpy >=1.8|1.7*', True),    ('numpy ==1.7', False),
             ('numpy >=1.5,>1.6', True),    ('numpy ==1.7.1', True),
+            ('numpy ==1.7.1.0', True),     ('numpy==1.7.1.0.0', True),
             ('numpy >=1,*.7.*', True),     ('numpy *.7.*,>=1', True),
             ('numpy >=1,*.8.*', False),    ('numpy >=2,*.7.*', False),
             ('numpy 1.6*|1.7*', True),     ('numpy 1.6*|1.8*', False),
@@ -560,6 +561,14 @@ def test_parse_equal_equal(self):
             "name": "numpy",
             "version": "1.7",
         }
+        assert _parse_spec_str("numpy=1.7") == {
+            "name": "numpy",
+            "version": "1.7*",
+        }
+        assert _parse_spec_str("numpy =1.7") == {
+            "name": "numpy",
+            "version": "1.7*",
+        }
 
     def test_parse_hard(self):
         assert _parse_spec_str("numpy>1.8,<2|==1.7") == {