Skip to content

Commit

Permalink
gdb/blink.py Fix string encoding error
Browse files Browse the repository at this point in the history
ustring_to_string attempts to concatenate an error message, which is a
string, with the result of a string encoded into utf-8, which is bytes.
For this to work in Python3 they need to be the same type so ensure we
also encode the error message.

Change-Id: I2591784641bb38eec0c168080acc84230f4932a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4790023
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1185149}
  • Loading branch information
bokand authored and Chromium LUCI CQ committed Aug 18, 2023
1 parent 70c2694 commit 48336f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion third_party/blink/tools/gdb/blink.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def ustring_to_string(ptr, length=None):
char_vals = [int((ptr + i).dereference()) for i in range(length)]
string = struct.pack('H' * length, *char_vals).decode(
'utf-16', 'replace').encode('utf-8')
return string + error_message
return string + error_message.encode('utf-8')


def lstring_to_string(ptr, length=None):
Expand Down

0 comments on commit 48336f0

Please sign in to comment.