From df95149198744c258ed6856044ac5e79e6b81404 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 19 Jan 2015 18:10:16 +0100 Subject: Improved unicode handling when using os.environ or GitConfigParser Assured unicode values are supported when reading the configuration, and when getting author/committer information from the environment. Fixes #237 --- git/util.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'git/util.py') diff --git a/git/util.py b/git/util.py index 010130cb..5385455a 100644 --- a/git/util.py +++ b/git/util.py @@ -17,7 +17,11 @@ import threading # NOTE: Some of the unused imports might be used/imported by others. # Handle once test-cases are back up and running. from .exc import GitCommandError -from .compat import MAXSIZE +from .compat import ( + MAXSIZE, + defenc, + PY3 +) # Most of these are unused here, but are for use by git-python modules so these # don't see gitdb all the time. Flake of course doesn't like it. @@ -364,7 +368,11 @@ class Actor(object): for attr, evar, cvar, default in (('name', env_name, cls.conf_name, default_name), ('email', env_email, cls.conf_email, default_email)): try: - setattr(actor, attr, os.environ[evar]) + val = os.environ[evar] + if not PY3: + val = val.decode(defenc) + # end assure we don't get 'invalid strings' + setattr(actor, attr, val) except KeyError: if config_reader is not None: setattr(actor, attr, config_reader.get_value('user', cvar, default)) -- cgit v1.2.1