diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-19 18:10:16 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-19 18:10:16 +0100 |
commit | df95149198744c258ed6856044ac5e79e6b81404 (patch) | |
tree | e583207230b9ddfbd170c01d218168ca12fea07b /git/util.py | |
parent | d5054fdb1766cb035a1186c3cef4a14472fee98d (diff) | |
download | gitpython-df95149198744c258ed6856044ac5e79e6b81404.tar.gz |
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
Diffstat (limited to 'git/util.py')
-rw-r--r-- | git/util.py | 12 |
1 files changed, 10 insertions, 2 deletions
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)) |