Skip to content

Commit

Permalink
Merge pull request #10 from pierriko/groovy-devel
Browse files Browse the repository at this point in the history
Fix deserialize bytes in Python3
  • Loading branch information
dirk-thomas committed May 31, 2013
2 parents aa89c73 + ac4c1f7 commit 11e483b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/genpy/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,13 @@ def string_serializer_generator(package, type_, name, serialize):
yield "%s = str[start:end]" % var
else:
yield "end += length"
yield "if python3:"
yield INDENT+"%s = str[start:end].decode('utf-8')" % (var) #If messages are python3-decode back to unicode
yield "else:"
yield INDENT+"%s = str[start:end]" % (var)
if base_type in ['uint8', 'char']:
yield "%s = str[start:end]" % (var)
else:
yield "if python3:"
yield INDENT+"%s = str[start:end].decode('utf-8')" % (var) #If messages are python3-decode back to unicode
yield "else:"
yield INDENT+"%s = str[start:end]" % (var)


def array_serializer_generator(msg_context, package, type_, name, serialize, is_numpy):
Expand Down

0 comments on commit 11e483b

Please sign in to comment.