# Buggy code
def main(*args):
    if not args:
        args = sys.argv

    if not args:
        args = sys.argv

    log.debug("conda.cli.main called with %s", args)
    if len(args) > 1:
        try:
            argv1 = args[1].strip()
            if argv1.startswith(".."):
                import conda.cli.activate as activate

                activate.main()
                return
            if argv1 in ("activate", "deactivate"):
                from ..exceptions import CommandNotFoundError

                raise CommandNotFoundError(argv1)
        except Exception as e:
            from ..exceptions import handle_exception

            return handle_exception(e)

    from ..exceptions import conda_exception_handler

    return conda_exception_handler(_main, *args)


# Traceback (UnicodeEncodeError)
(root) c:\msys64\home\kfranz\continuum\conda>python -m conda create -n qtcrΞator qt=5.6.2 python=3.6
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment C:\conda-root\envs\qtcrΞator:

The following NEW packages will be INSTALLED:

icu:            57.1-vc14_0   [vc14]
jpeg:           9b-vc14_0     [vc14]
libpng:         1.6.27-vc14_0 [vc14]
openssl:        1.0.2k-vc14_0 [vc14]
pip:            9.0.1-py36_1
python:         3.6.1-2
qt:             5.6.2-vc14_3  [vc14]
setuptools:     27.2.0-py36_1
vs2015_runtime: 14.0.25123-0
wheel:          0.29.0-py36_0
zlib:           1.2.8-vc14_3  [vc14]

Proceed ([y]/n)?

icu-57.1-vc14_ 100% |###############################| Time: 0:00:03  10.44 MB/s
jpeg-9b-vc14_0 100% |###############################| Time: 0:00:00  19.74 MB/s
python-3.6.1-2 100% |###############################| Time: 0:00:03  10.96 MB/s
zlib-1.2.8-vc1 100% |###############################| Time: 0:00:00   0.00  B/s
libpng-1.6.27- 100% |###############################| Time: 0:00:00  10.97 MB/s
qt-5.6.2-vc14_ 100% |###############################| Time: 0:00:05  11.55 MB/s
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues



Current conda install:

platform : win-64
conda version : 4.3.18.post13+e7b1a6bf
conda is private : False
conda-env version : 4.3.18.post13+e7b1a6bf
conda-build version : not installed
python version : 3.6.1.final.0
requests version : 2.12.4
root environment : C:\conda-root  (writable)
default environment : C:\conda-root
envs directories : C:\conda-root\envs
C:\Users\kfranz\AppData\Local\conda\conda\envs
C:\Users\kfranz\.conda\envs
package cache : C:\conda-root\pkgs
C:\Users\kfranz\AppData\Local\conda\conda\pkgs
channel URLs : https://repo.continuum.io/pkgs/free/win-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/win-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/win-64
https://repo.continuum.io/pkgs/pro/noarch
https://repo.continuum.io/pkgs/msys2/win-64
https://repo.continuum.io/pkgs/msys2/noarch
config file : C:\Users\kfranz\.condarc
offline mode : False
user-agent : conda/4.3.18.post13+e7b1a6bf requests/2.12.4 CPython/3.6.1 Windows/10 Windows/10.0.14393
administrator : unknown

`$ c:\msys64\home\kfranz\continuum\conda\conda\__main__.py create -n qtcrΞator qt=5.6.2 python=3.6`




Traceback (most recent call last):
File "c:\msys64\home\kfranz\continuum\conda\conda\exceptions.py", line 632, in conda_exception_handler
return_value = func(*args, **kwargs)
File "c:\msys64\home\kfranz\continuum\conda\conda\cli\main.py", line 134, in _main
exit_code = args.func(args, p)
File "c:\msys64\home\kfranz\continuum\conda\conda\cli\main_create.py", line 68, in execute
install(args, parser, 'create')
File "c:\msys64\home\kfranz\continuum\conda\conda\cli\install.py", line 357, in install
execute_actions(actions, index, verbose=not context.quiet)
File "c:\msys64\home\kfranz\continuum\conda\conda\plan.py", line 830, in execute_actions
execute_instructions(plan, index, verbose)
File "c:\msys64\home\kfranz\continuum\conda\conda\history.py", line 75, in __exit__
self.update('exit')
File "c:\msys64\home\kfranz\continuum\conda\conda\history.py", line 104, in update
self.write_changes(last, curr)
File "c:\msys64\home\kfranz\continuum\conda\conda\history.py", line 263, in write_changes
write_head(fo)
File "c:\msys64\home\kfranz\continuum\conda\conda\history.py", line 27, in write_head
fo.write("# cmd: %s\n" % (' '.join(sys.argv)))
File "C:\conda-root\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u039e' in position 77: character maps to <undefined>

# Fixed code
def main(*args):
    if not args:
        args = sys.argv

    args = tuple(_ensure_text_type(s) for s in args)

    log.debug("conda.cli.main called with %s", args)
    if len(args) > 1:
        try:
            argv1 = args[1].strip()
            if argv1.startswith(".."):
                import conda.cli.activate as activate

                activate.main()
                return
            if argv1 in ("activate", "deactivate"):
                from ..exceptions import CommandNotFoundError

                raise CommandNotFoundError(argv1)
        except Exception as e:
            from ..exceptions import handle_exception

            return handle_exception(e)

    from ..exceptions import conda_exception_handler

    return conda_exception_handler(_main, *args)