Repository: conda/conda

Issue:
conda.gateways.disk.delete.rm and conda.gateways.disk.delete.retry disagree on arguments
Using Conda 4.5.4 with Python 2.7.14 on Windows, I'm getting the following error when using `conda remove`:

```    Traceback (most recent call last):
      File "C:\bin\Miniconda2\lib\site-packages\conda\exceptions.py", line 819, in __call__
        return func(*args, **kwargs)
      File "C:\bin\Miniconda2\lib\site-packages\conda\cli\main.py", line 78, in _main
        exit_code = do_call(args, p)
      File "C:\bin\Miniconda2\lib\site-packages\conda\cli\conda_argparse.py", line 77, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "C:\bin\Miniconda2\lib\site-packages\conda\cli\main_install.py", line 12, in execute
        delete_trash()
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 68, in delete_trash
        backoff_rmdir(path, max_tries=1)
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 145, in backoff_rmdir
        _rmdir(join(root, dir))
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 134, in _rmdir
        exp_backoff_fn(rmtree, path, onerror=retry, max_tries=max_tries)
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\__init__.py", line 30, in exp_backoff_fn
        result = fn(*args, **kwargs)
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 212, in rmtree
        visit_files(root, files)
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 200, in visit_files
        rm(unlink, join(root, target))
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 196, in rm
        onerror(fn, childpath, sys.exc_info()[0])
      File "C:\bin\Miniconda2\lib\site-packages\conda\gateways\disk\delete.py", line 126, in retry
        if getattr(exc_info[1], 'errno', None) == ENOENT:
    TypeError: 'type' object has no attribute '__getitem__'
```

Looking at the Conda source, this appears to be because `conda.gateways.disk.delete.retry` expects to receive the tuple returned by of `sys.exc_info()`, so that it can analyse the exception error message, but `conda.gateways.disk.delete.rm` passes it only the first entry in that tuple (the exception type).

(There's an underlying problem that it seems the .trash directory isn't being deleted, but that should throw a more helpful error in `delete_trash`)


Discussion:
Yeah all this is tied into https://github.com/conda/conda/issues/6631, which I've tried [more](https://github.com/conda/conda/pull/6660) [than](https://github.com/conda/conda/pull/7077) [once](https://github.com/conda/conda/pull/7083) to wrap up.  I still haven't figured out the bizarre file locking we're seeing on appveyor in those PRs.
The code for Python 2 reimplementation of `rmtree` seems buggy: the call `onerror(fn, childpath, sys.exc_info()[0])` should be `onerror(fn, childpath, sys.exc_info())`
here: 
https://github.com/conda/conda/blob/1471f043eed980d62f46944e223f0add6a9a790b/conda/gateways/disk/delete.py#L190-L198
Should be straightforward to fix.

Might not fix the appveyor strangeness, but the above seems the cause for this bugreport.
I'm seeing this issue on Appveyor *only* for Python 2 but not Python 3, so presumably the Appveyor locking stuff is a separate problem, and the issue here can occur independently of it.
@pv  Had the same bug, fix worked for me thanks. 

Resolving patch:
diff --git a/conda/gateways/disk/delete.py b/conda/gateways/disk/delete.py
--- a/conda/gateways/disk/delete.py
+++ b/conda/gateways/disk/delete.py
@@ -214,7 +214,7 @@ def rm(fn, childpath):
                     if onerror is None:
                         raise
                     else:
-                        onerror(fn, childpath, sys.exc_info()[0])
+                        onerror(fn, childpath, sys.exc_info())
 
         def visit_files(root, targets):
             for target in targets:


Test patch: