Repository: conda/conda

Issue:
On Windows, conda 4.0.5-py35_0 cannot be updated to 4.3.0-py35_1
On a fresh install of the latest Miniconda on Windows, the following fails:

`conda update -c conda-canary --all`

Giving:

```
Fetching package metadata: ......
Solving package specifications: .........

Package plan for installation in environment C:\Users\ray\m2-x64-3.5:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-env-2.6.0            |                0          498 B
    vs2015_runtime-14.0.25123  |                0         1.9 MB
    python-3.5.2               |                0        30.3 MB
    pycosat-0.6.1              |           py35_1          80 KB
    pycrypto-2.6.1             |           py35_4         481 KB
    pywin32-220                |           py35_1        10.4 MB
    pyyaml-3.12                |           py35_0         118 KB
    requests-2.12.4            |           py35_0         791 KB
    ruamel_yaml-0.11.14        |           py35_0         217 KB
    setuptools-27.2.0          |           py35_1         761 KB
    menuinst-1.4.2             |           py35_1         108 KB
    pip-9.0.1                  |           py35_1         1.7 MB
    conda-4.3.0                |           py35_1         510 KB
    ------------------------------------------------------------
                                           Total:        47.3 MB

The following NEW packages will be INSTALLED:

    pywin32:        220-py35_1
    ruamel_yaml:    0.11.14-py35_0

The following packages will be UPDATED:

    conda:          4.0.5-py35_0    --> 4.3.0-py35_1
    conda-env:      2.4.5-py35_0    --> 2.6.0-0
    menuinst:       1.3.2-py35_0    --> 1.4.2-py35_1
    pip:            8.1.1-py35_1    --> 9.0.1-py35_1
    pycosat:        0.6.1-py35_0    --> 0.6.1-py35_1
    pycrypto:       2.6.1-py35_3    --> 2.6.1-py35_4
    python:         3.5.1-4         --> 3.5.2-0
    pyyaml:         3.11-py35_3     --> 3.12-py35_0
    requests:       2.9.1-py35_0    --> 2.12.4-py35_0
    setuptools:     20.3-py35_0     --> 27.2.0-py35_1
    vs2015_runtime: 14.00.23026.0-0 --> 14.0.25123-0

Proceed ([y]/n)? y

menuinst-1.4.2 100% |###############################| Time: 0:00:00   2.35 MB/s
Fetching packages ...
conda-env-2.6. 100% |###############################| Time: 0:00:00   0.00  B/s
vs2015_runtime 100% |###############################| Time: 0:00:00   9.24 MB/s
python-3.5.2-0 100% |###############################| Time: 0:00:02  11.57 MB/s
pycosat-0.6.1- 100% |###############################| Time: 0:00:00   2.61 MB/s
pycrypto-2.6.1 100% |###############################| Time: 0:00:00   4.51 MB/s
pywin32-220-py 100% |###############################| Time: 0:00:00  10.85 MB/s
pyyaml-3.12-py 100% |###############################| Time: 0:00:00   2.57 MB/s
requests-2.12. 100% |###############################| Time: 0:00:00   5.76 MB/s
ruamel_yaml-0. 100% |###############################| Time: 0:00:00   2.84 MB/s
setuptools-27. 100% |###############################| Time: 0:00:00   4.53 MB/s
pip-9.0.1-py35 100% |###############################| Time: 0:00:00   5.70 MB/s
conda-4.3.0-py 100% |###############################| Time: 0:00:00 530.91 kB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%
Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 516, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 84, in _main
    from ..base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\Scripts\conda-script.py", line 5, in <module>
    sys.exit(conda.cli.main())
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 152, in main
    return conda_exception_handler(_main)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 532, in conda_exception_handler
    print_unexpected_error_message(e)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 463, in print_unexpected_error_message
    from conda.base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 516, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 84, in _main
    from ..base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\Scripts\conda-script.py", line 5, in <module>
    sys.exit(conda.cli.main())
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 152, in main
    return conda_exception_handler(_main)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 532, in conda_exception_handler
    print_unexpected_error_message(e)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 463, in print_unexpected_error_message
    from conda.base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
```

On Windows, conda 4.0.5-py35_0 cannot be updated to 4.3.0-py35_1
On a fresh install of the latest Miniconda on Windows, the following fails:

`conda update -c conda-canary --all`

Giving:

```
Fetching package metadata: ......
Solving package specifications: .........

Package plan for installation in environment C:\Users\ray\m2-x64-3.5:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-env-2.6.0            |                0          498 B
    vs2015_runtime-14.0.25123  |                0         1.9 MB
    python-3.5.2               |                0        30.3 MB
    pycosat-0.6.1              |           py35_1          80 KB
    pycrypto-2.6.1             |           py35_4         481 KB
    pywin32-220                |           py35_1        10.4 MB
    pyyaml-3.12                |           py35_0         118 KB
    requests-2.12.4            |           py35_0         791 KB
    ruamel_yaml-0.11.14        |           py35_0         217 KB
    setuptools-27.2.0          |           py35_1         761 KB
    menuinst-1.4.2             |           py35_1         108 KB
    pip-9.0.1                  |           py35_1         1.7 MB
    conda-4.3.0                |           py35_1         510 KB
    ------------------------------------------------------------
                                           Total:        47.3 MB

The following NEW packages will be INSTALLED:

    pywin32:        220-py35_1
    ruamel_yaml:    0.11.14-py35_0

The following packages will be UPDATED:

    conda:          4.0.5-py35_0    --> 4.3.0-py35_1
    conda-env:      2.4.5-py35_0    --> 2.6.0-0
    menuinst:       1.3.2-py35_0    --> 1.4.2-py35_1
    pip:            8.1.1-py35_1    --> 9.0.1-py35_1
    pycosat:        0.6.1-py35_0    --> 0.6.1-py35_1
    pycrypto:       2.6.1-py35_3    --> 2.6.1-py35_4
    python:         3.5.1-4         --> 3.5.2-0
    pyyaml:         3.11-py35_3     --> 3.12-py35_0
    requests:       2.9.1-py35_0    --> 2.12.4-py35_0
    setuptools:     20.3-py35_0     --> 27.2.0-py35_1
    vs2015_runtime: 14.00.23026.0-0 --> 14.0.25123-0

Proceed ([y]/n)? y

menuinst-1.4.2 100% |###############################| Time: 0:00:00   2.35 MB/s
Fetching packages ...
conda-env-2.6. 100% |###############################| Time: 0:00:00   0.00  B/s
vs2015_runtime 100% |###############################| Time: 0:00:00   9.24 MB/s
python-3.5.2-0 100% |###############################| Time: 0:00:02  11.57 MB/s
pycosat-0.6.1- 100% |###############################| Time: 0:00:00   2.61 MB/s
pycrypto-2.6.1 100% |###############################| Time: 0:00:00   4.51 MB/s
pywin32-220-py 100% |###############################| Time: 0:00:00  10.85 MB/s
pyyaml-3.12-py 100% |###############################| Time: 0:00:00   2.57 MB/s
requests-2.12. 100% |###############################| Time: 0:00:00   5.76 MB/s
ruamel_yaml-0. 100% |###############################| Time: 0:00:00   2.84 MB/s
setuptools-27. 100% |###############################| Time: 0:00:00   4.53 MB/s
pip-9.0.1-py35 100% |###############################| Time: 0:00:00   5.70 MB/s
conda-4.3.0-py 100% |###############################| Time: 0:00:00 530.91 kB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%
Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 516, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 84, in _main
    from ..base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\Scripts\conda-script.py", line 5, in <module>
    sys.exit(conda.cli.main())
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 152, in main
    return conda_exception_handler(_main)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 532, in conda_exception_handler
    print_unexpected_error_message(e)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 463, in print_unexpected_error_message
    from conda.base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 516, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 84, in _main
    from ..base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ray\m2-x64-3.5\Scripts\conda-script.py", line 5, in <module>
    sys.exit(conda.cli.main())
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\cli\main.py", line 152, in main
    return conda_exception_handler(_main)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 532, in conda_exception_handler
    print_unexpected_error_message(e)
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\exceptions.py", line 463, in print_unexpected_error_message
    from conda.base.context import context
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\context.py", line 12, in <module>
    from .constants import (APP_NAME, DEFAULT_CHANNELS, DEFAULT_CHANNEL_ALIAS, ROOT_ENV_NAME,
  File "C:\Users\ray\m2-x64-3.5\lib\site-packages\conda\base\constants.py", line 15
    PREFIX_PLACEHOLDER = 'C:\Users\ray\m2-x64-3.5'
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
```



Discussion:

Resolving patch:
diff --git a/conda/base/constants.py b/conda/base/constants.py
--- a/conda/base/constants.py
+++ b/conda/base/constants.py
@@ -12,7 +12,10 @@
 from os.path import join
 
 on_win = bool(sys.platform == "win32")
-PREFIX_PLACEHOLDER = '/opt/anaconda1anaconda2anaconda3'
+PREFIX_PLACEHOLDER = ('/opt/anaconda1anaconda2'
+                      # this is intentionally split into parts, such that running
+                      # this program on itself will leave it unchanged
+                      'anaconda3')
 
 machine_bits = 8 * tuple.__itemsize__
 


Test patch:
diff --git a/tests/core/test_portability.py b/tests/core/test_portability.py
--- a/tests/core/test_portability.py
+++ b/tests/core/test_portability.py
@@ -51,11 +51,11 @@ def test_shebang_regex_matches(self):
     def test_replace_long_shebang(self):
         content_line = b"content line " * 5
 
-        # # simple shebang no replacement
-        # shebang = b"#!/simple/shebang/escaped\\ space --and --flags -x"
-        # data = b'\n'.join((shebang, content_line, content_line, content_line))
-        # new_data = replace_long_shebang(FileMode.text, data)
-        # assert data == new_data
+        # simple shebang no replacement
+        shebang = b"#!/simple/shebang/escaped\\ space --and --flags -x"
+        data = b'\n'.join((shebang, content_line, content_line, content_line))
+        new_data = replace_long_shebang(FileMode.text, data)
+        assert data == new_data
 
         # long shebang with truncation
         #   executable name is 'escaped space'