Default to UTF-8 encoding when locale doesn't specify one (as Python defaults

to ascii); thanks Stefano Rivera.
This commit is contained in:
Loïc Minier 2013-05-15 02:10:04 +02:00
parent 0aaa0f1f4a
commit a41422a7f4

View File

@ -177,6 +177,7 @@ def ubu_email(name=None, email=None, export=True):
# decode env var or gecos raw string with the current locale's encoding
encoding = locale.getdefaultlocale()[1]
if encoding:
name = name.decode(encoding)
if not encoding:
encoding = 'utf-8'
name = name.decode(encoding)
return name, email