summaryrefslogtreecommitdiff
path: root/gitlab.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2013-09-14 08:47:18 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2013-09-14 08:49:49 +0200
commit64cead6d48f8c6a65ca89f90abc2fa010a36adaf (patch)
tree0d75bb3b91825d910566bb4eda7966236fc97089 /gitlab.py
parentceda87a6cac2558caeecd9c7bc96c2a08cb36cf9 (diff)
downloadgitlab-64cead6d48f8c6a65ca89f90abc2fa010a36adaf.tar.gz
Fix strings encoding (Closes #6)
Diffstat (limited to 'gitlab.py')
-rw-r--r--gitlab.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/gitlab.py b/gitlab.py
index 22e5a3b..fc34086 100644
--- a/gitlab.py
+++ b/gitlab.py
@@ -18,6 +18,7 @@
import json
import requests
+import sys
__title__ = 'python-gitlab'
__version__ = '0.3'
@@ -298,8 +299,10 @@ class Gitlab(object):
# build a dict of data that can really be sent to server
d = {}
for k, v in obj.__dict__.items():
- if type(v) in (int, str, unicode, bool):
+ if type(v) in (int, str, bool):
d[k] = str(v)
+ elif type(v) == unicode:
+ d[k] = str(v.encode(sys.stdout.encoding, "replace"))
try:
r = requests.put(url, d, headers=self.headers, verify=self.ssl_verify)
@@ -520,6 +523,8 @@ class GitlabObject(object):
elif isinstance(obj, list):
s = ", ".join([GitlabObject._obj_to_str(x) for x in obj])
return "[ %s ]" %s
+ elif isinstance(obj, unicode):
+ return obj.encode(sys.stdout.encoding, "replace")
else:
return str(obj)
@@ -530,7 +535,7 @@ class GitlabObject(object):
if k == self.idAttr:
continue
v = self.__dict__[k]
- pretty_k = k.replace('_', '-')
+ pretty_k = k.replace('_', '-').encode(sys.stdout.encoding, "replace")
if isinstance(v, GitlabObject):
if depth == 0:
print("%s:" % pretty_k)