Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64cead6

Browse files
author
Gauvain Pocentek
committed
Fix strings encoding (Closes#6)
1 parentceda87a commit64cead6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

‎ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 0.4
2+
3+
* Fix strings encoding (Closes #6)
4+
15
Version 0.3
26

37
* Use PRIVATE-TOKEN header for passing the auth token

‎gitlab.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
importjson
2020
importrequests
21+
importsys
2122

2223
__title__='python-gitlab'
2324
__version__='0.3'
@@ -298,8 +299,10 @@ def update(self, obj):
298299
# build a dict of data that can really be sent to server
299300
d= {}
300301
fork,vinobj.__dict__.items():
301-
iftype(v)in (int,str,unicode,bool):
302+
iftype(v)in (int,str,bool):
302303
d[k]=str(v)
304+
eliftype(v)==unicode:
305+
d[k]=str(v.encode(sys.stdout.encoding,"replace"))
303306

304307
try:
305308
r=requests.put(url,d,headers=self.headers,verify=self.ssl_verify)
@@ -520,6 +523,8 @@ def _obj_to_str(obj):
520523
elifisinstance(obj,list):
521524
s=", ".join([GitlabObject._obj_to_str(x)forxinobj])
522525
return"[ %s ]"%s
526+
elifisinstance(obj,unicode):
527+
returnobj.encode(sys.stdout.encoding,"replace")
523528
else:
524529
returnstr(obj)
525530

@@ -530,7 +535,7 @@ def pretty_print(self, depth=0):
530535
ifk==self.idAttr:
531536
continue
532537
v=self.__dict__[k]
533-
pretty_k=k.replace('_','-')
538+
pretty_k=k.replace('_','-').encode(sys.stdout.encoding,"replace")
534539
ifisinstance(v,GitlabObject):
535540
ifdepth==0:
536541
print("%s:"%pretty_k)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp