Skip to content

Commit

Permalink
more python3 string fixes: parse lists of bytes to strings
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@6184 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 27, 2014
1 parent a62082e commit c23011b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ def listget(self, k, default_value=[], item_type=None, max_items=None):
if v is None:
return default_value
assert type(v) in (list, tuple), "expected a list or tuple value for %s but got %s" % (k, type(v))
aslist = list(v)
if item_type:
for x in v:
for i in range(len(aslist)):
x = aslist[i]
if sys.version > '3' and type(x)==bytes and item_type==str:
x = bytestostr(x)
aslist[i] = x
assert type(x)==item_type, "invalid item type for %s %s: expected %s but got %s" % (type(v), k, item_type, type(x))
if max_items is not None:
assert len(v)<=max_items, "too many items in %s %s: maximum %s allowed, but got %s" % (type(v), k, max_items, len(v))
return v
return aslist


def log_screen_sizes(root_w, root_h, sizes):
Expand Down

0 comments on commit c23011b

Please sign in to comment.