Commit 7a614338 authored by sangwoo.ko's avatar sangwoo.ko Committed by Commit Bot

Decode datetime string when it's not utf-8

If the encoding is not utf-8, datatime_now() will yield

> 'now': '2019-05-17 \xbf\xc0\xc0\xfc 11:28:31'(with CP949),

and it fails to decode it with utf-8 afterward.

>  traces_readme, TRACES_README_FORMAT % git_push_metadata)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xbf in position 17: invalid start byte

For further information, please check out
https://bugs.chromium.org/p/chromium/issues/detail?id=955206#c16

Bug: 955206
Change-Id: I2733849735adc0361140b042ce617522c58fcc78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1621576Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Sang Woo Ko <sangwoo108@chromium.org>
parent c9e22835
......@@ -2552,6 +2552,10 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
git_info_zip = trace_name + '-git-info'
git_push_metadata['now'] = datetime_now().strftime('%c')
if sys.stdin.encoding != 'utf-8':
git_push_metadata['now'] = git_push_metadata['now'].decode(
sys.stdin.encoding)
git_push_metadata['trace_name'] = trace_name
gclient_utils.FileWrite(
traces_readme, TRACES_README_FORMAT % git_push_metadata)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment