summaryrefslogtreecommitdiff
path: root/gitlab.py
diff options
context:
space:
mode:
authorCrestez Dan Leonard <lcrestez@ixiacom.com>2014-07-28 20:42:46 +0300
committerCrestez Dan Leonard <lcrestez@ixiacom.com>2014-07-28 20:50:54 +0300
commitec185cf416adce98e0a3ef338720091c0e2a53fe (patch)
treec02edac022249de678ebfc057a3bf86296f9ff96 /gitlab.py
parente236fd94c48b949bbbc8e0dc2d55ebfaa1ef0069 (diff)
downloadgitlab-ec185cf416adce98e0a3ef338720091c0e2a53fe.tar.gz
Fix encoding error when updating with redirected output
When output is redirected sys.stdout.encoding is None. Fix this by always encoding to utf-8, assuming gitlab handles that. The encoding used by the local system is irrelevant here.
Diffstat (limited to 'gitlab.py')
-rw-r--r--gitlab.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/gitlab.py b/gitlab.py
index 7eb844f..a7ec487 100644
--- a/gitlab.py
+++ b/gitlab.py
@@ -89,6 +89,8 @@ class Gitlab(object):
self.email = email
self.password = password
self.ssl_verify = ssl_verify
+ # Gitlab should handle UTF-8
+ self.gitlab_encoding = 'UTF-8'
def auth(self):
"""Performs an authentication using either the private token, or the
@@ -302,7 +304,7 @@ class Gitlab(object):
if type(v) in (int, str, bool):
d[k] = str(v)
elif type(v) == unicode:
- d[k] = str(v.encode(sys.stdout.encoding, "replace"))
+ d[k] = str(v.encode(self.gitlab_encoding, "replace"))
try:
r = requests.put(url, d,