Fix unicode bug with special characters in path names.

Decode path before using it in join (Python2 only).
This commit is contained in:
Simon Conseil
2015-12-15 23:19:19 +01:00
parent c5a458a9d7
commit e8fe30ebf7

View File

@@ -140,15 +140,14 @@ def read_settings(filename=None):
enc = locale.getpreferredencoding() if PY2 else None
for p in paths:
path = settings[p]
if path and not isabs(path):
settings[p] = abspath(normpath(join(settings_path, path)))
logger.debug("Rewrite %s : %s -> %s", p, path, settings[p])
# paths must to be unicode strings so that os.walk will return
# unicode dirnames and filenames
if PY2 and isinstance(settings[p], str):
settings[p] = settings[p].decode(enc)
path = settings[p]
if path and not isabs(path):
settings[p] = abspath(normpath(join(settings_path, path)))
logger.debug("Rewrite %s : %s -> %s", p, path, settings[p])
if settings['title'] and not isinstance(settings['title'], text_type):
settings['title'] = settings['title'].decode('utf8')