Repository: conda/conda

Issue:
RepresenterError('cannot represent an object: prevent',)
```
error: RepresenterError('cannot represent an object: prevent',)
command: C:\tools\Anaconda3\Scripts\conda config --set path_conflict prevent
user_agent: conda/4.4.4 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.16299
_messageid: -9223372036843225525
_messagetime: 1514570427640 / 2017-12-29 12:00:27

Traceback (most recent call last):
  File "C:\tools\Anaconda3\lib\site-packages\conda\exceptions.py", line 724, in __call__
    return func(*args, **kwargs)
  File "C:\tools\Anaconda3\lib\site-packages\conda\cli\main.py", line 78, in _main
    exit_code = do_call(args, p)
  File "C:\tools\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 75, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File "C:\tools\Anaconda3\lib\site-packages\conda\cli\main_config.py", line 29, in execute
    execute_config(args, parser)
  File "C:\tools\Anaconda3\lib\site-packages\conda\cli\main_config.py", line 312, in execute_config
    rc.write(yaml_dump(rc_config))
  File "C:\tools\Anaconda3\lib\site-packages\conda\common\serialize.py", line 81, in yaml_dump
    indent=2)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\main.py", line 254, in dump
    version=version, tags=tags, block_seq_indent=block_seq_indent)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\main.py", line 224, in dump_all
    dumper.represent(data)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\representer.py", line 49, in represent
    node = self.represent_data(data)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\representer.py", line 83, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\representer.py", line 852, in represent_dict
    return self.represent_mapping(tag, data)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\representer.py", line 698, in represent_mapping
    node_value = self.represent_data(item_value)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\representer.py", line 93, in represent_data
    node = self.yaml_representers[None](self, data)
  File "C:\tools\Anaconda3\lib\site-packages\ruamel_yaml\representer.py", line 324, in represent_undefined
    raise RepresenterError("cannot represent an object: %s" % data)
ruamel_yaml.representer.RepresenterError: cannot represent an object: prevent
```


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
@@ -11,11 +11,12 @@
 
 from .. import CondaError
 from .._vendor.auxlib.entity import EntityEncoder
+from ..base.constants import PathConflict, SafetyChecks
 from ..base.context import context, sys_rc_path, user_rc_path
 from ..common.compat import isiterable, iteritems, itervalues, string_types, text_type
 from ..common.configuration import pretty_list, pretty_map
 from ..common.io import timeout
-from ..common.serialize import yaml_dump, yaml_load
+from ..common.serialize import yaml, yaml_dump, yaml_load
 
 try:
     from cytoolz.itertoolz import concat, groupby
@@ -309,6 +310,17 @@ def execute_config(args, parser):
 
     # config.rc_keys
     if not args.get:
+
+        # Add representers for enums.
+        # Because a representer cannot be added for the base Enum class (it must be added for
+        # each specific Enum subclass), and because of import rules), I don't know of a better
+        # location to do this.
+        def enum_representer(dumper, data):
+            return dumper.represent_str(str(data))
+
+        yaml.representer.RoundTripRepresenter.add_representer(SafetyChecks, enum_representer)
+        yaml.representer.RoundTripRepresenter.add_representer(PathConflict, enum_representer)
+
         try:
             with open(rc_path, 'w') as rc:
                 rc.write(yaml_dump(rc_config))


Test patch: