Repository: conda/conda

Issue:
Conda 4.4.2 YAML parsing bug
When trying to build my environment with conda 4.4.2, I get the following error. This did not occur with previous versions.

If I force downgrade conda to 4.3.31 before trying to build my environment, it works fine.

```
    Traceback (most recent call last):
      File "[conda_dir]/lib/python2.7/site-packages/conda/exceptions.py", line 722, in __call__
        return func(*args, **kwargs)
      File "[conda_dir]/lib/python2.7/site-packages/conda_env/cli/main.py", line 74, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "[conda_dir]/lib/python2.7/site-packages/conda_env/cli/main_create.py", line 79, in execute
        directory=os.getcwd())
      File "[conda_dir]/lib/python2.7/site-packages/conda_env/specs/__init__.py", line 20, in detect
        if spec.can_handle():
      File "[conda_dir]/lib/python2.7/site-packages/conda_env/specs/yaml_file.py", line 14, in can_handle
        self._environment = env.from_file(self.filename)
      File "[conda_dir]/lib/python2.7/site-packages/conda_env/env.py", line 84, in from_file
        return from_yaml(yamlstr, filename=filename)
      File "[conda_dir]/lib/python2.7/site-packages/conda_env/env.py", line 72, in from_yaml
        data = yaml_load(yamlstr)
      File "[conda_dir]/lib/python2.7/site-packages/conda/common/serialize.py", line 54, in yaml_load
        return yaml.load(string, Loader=yaml.RoundTripLoader, version="1.2")
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/main.py", line 75, in load
        return loader.get_single_data()
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/constructor.py", line 62, in get_single_data
        return self.construct_document(node)
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/constructor.py", line 71, in construct_document
        for dummy in generator:
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/constructor.py", line 1049, in construct_yaml_map
        self.construct_mapping(node, data)
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/constructor.py", line 978, in construct_mapping
        value = self.construct_object(value_node, deep=deep)
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/constructor.py", line 120, in construct_object
        data = next(generator)
      File "[conda_dir]/lib/python2.7/site-packages/ruamel_yaml/constructor.py", line 1115, in construct_undefined
        node.start_mark)
    ConstructorError: could not determine a constructor for the tag '!!python/unicode'
      in "<byte string>", line 191, column 9:
        prefix: !!python/unicode '/home/pair/dev ... 
                ^

  environment variables:
                 CIO_TEST=<not set>
               CONDA_ROOT=[conda_dir]
               MODULEPATH=/etc/scl/modulefiles:/etc/scl/modulefiles:/etc/scl/modulefiles:/usr/sh
                          are/Modules/modulefiles:/etc/modulefiles:/usr/share/modulefiles
                     PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/pair/.local/bi
                          n:/home/pair/bin:/home/pair/.local/bin:/home/pair/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
     TERMINATOR_DBUS_PATH=/net/tenshu/Terminator2
               WINDOWPATH=2

     active environment : None
       user config file : /home/pair/.condarc
 populated config files : 
          conda version : 4.4.2
    conda-build version : not installed
         python version : 2.7.14.final.0
       base environment : [conda_dir]  (writable)
           channel URLs : https://repo.continuum.io/pkgs/main/linux-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
          package cache : [conda_dir]/pkgs
                          /home/pair/.conda/pkgs
       envs directories : [conda_dir]/envs
                          /home/pair/.conda/envs
               platform : linux-64
             user-agent : conda/4.4.2 requests/2.18.4 CPython/2.7.14 Linux/4.13.16-100.fc25.x86_64 fedora/25 glibc/2.24
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
```


Discussion:
I actually have to downgrade to 4.3.31 to get this working again, sorry - 4.4.1 was a typo.
I'm unsure exactly what you mean here by "build my environment".  What is the command you're executing when getting the error?
Sorry. I'm running:

```conda env create --force --file <requirements yaml file>```
I see the problem, yes.  Also was confused thinking about changes between 4.4.1 and 4.4.2.  Having the diff be 4.3.1 and 4.4.x makes a lot more sense.
Could you give me an example of a requirements yaml file that reproduces this problem for you?  It could be stripped down from what you're using now, or completely made up.  The important part to reproduce this is probably having things related to `!!python/unicode` in the file.  I just don't know exactly where those are ending up for you.
Also, output of `conda list yaml --show-channel-urls`
Sorry for closing; bad click. I'm not very good at this.
Requirements file:

[requirements.yml](https://github.com/conda/conda/files/1582905/requirements.yml.txt)

Output of ```conda list yaml```:
```
# packages in environment at <conda dir>:
#
pyyaml                    3.12             py27h2d70dd7_1  
ruamel_yaml               0.11.14          py27h672d447_2  
yaml                      0.1.6                         0  
```

thanks that's helpful
If you need an immediate fix, you can just remove all the `!!python/unicode` stuff from the yaml file.  I'm working on a patch to the code though too.
Actually, I think the only thing you have to change is 

    prefix: !!python/unicode '<directory>'

to

    prefix: '<directory>'

Resolving patch:
diff --git a/conda/common/serialize.py b/conda/common/serialize.py
--- a/conda/common/serialize.py
+++ b/conda/common/serialize.py
@@ -64,6 +64,16 @@ def yaml_load_safe(string):
     return yaml.load(string, Loader=yaml.SafeLoader, version="1.2")
 
 
+def yaml_load_standard(string):
+    """Uses the default (unsafe) loader.
+
+    Examples:
+        >>> yaml_load_standard("prefix: !!python/unicode '/Users/darwin/test'")
+        {'prefix': '/Users/darwin/test'}
+    """
+    return yaml.load(string, Loader=yaml.Loader, version="1.2")
+
+
 def yaml_dump(object):
     """dump object to string"""
     return yaml.dump(object, Dumper=yaml.RoundTripDumper,
diff --git a/conda_env/env.py b/conda_env/env.py
--- a/conda_env/env.py
+++ b/conda_env/env.py
@@ -7,7 +7,7 @@
 
 from conda.base.context import context
 from conda.cli import common  # TODO: this should never have to import form conda.cli
-from conda.common.serialize import yaml_load
+from conda.common.serialize import yaml_load_standard
 from conda.core.linked_data import linked
 from conda.models.match_spec import MatchSpec
 from conda_env.yaml import dump
@@ -69,7 +69,7 @@ def from_environment(name, prefix, no_builds=False, ignore_channels=False):
 
 def from_yaml(yamlstr, **kwargs):
     """Load and return a ``Environment`` from a given ``yaml string``"""
-    data = yaml_load(yamlstr)
+    data = yaml_load_standard(yamlstr)
     if kwargs is not None:
         for key, value in kwargs.items():
             data[key] = value


Test patch: