rbgirshick / yacs

YACS -- Yet Another Configuration System
Apache License 2.0
1.27k stars 89 forks source link

UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-25: ordinal not in range(128) #30

Open lancexiang opened 4 years ago

lancexiang commented 4 years ago
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.