UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-25: ordinal not in range(128)
lancexiang opened this issue · 0 comments
lancexiang commented
File "/Users/lance/anaconda2/lib/python2.7/site-packages/yacs/config.py", line 513, in _check_and_coerce_cfg_value_type
original_type, replacement_type, original, replacement, full_key
The error occurs in merge_from_file('xxx.yml')
when I defined a path=''
in the default config and in the xxx.yml
setting with path: '你好' in chinese
.
I have debug this, it seems that in python 2.x, the yaml
package safe_load
method will auto convert the str with chinese to unicode
, so in this case, str mismatch with unicode.
Although I can redefined path=u''
to solve the problem for python2, but it really not pythonic, so I think it's a small bug. Can you fix the bug for python2.x?
Thanks.