Commit 4eac52c7 authored by Hayato Ito's avatar Hayato Ito Committed by Commit Bot

Let gdbinit work in Python 3

This is a quick fix for tools/gdb/gdbinit so it can be used in Python 3 environment too.

I don't think we need to support Python 3 in chromium development environment, however,
this is a very small fix so it could be okay.

The issue what this CL fixes is:

If user's `gdb` embeds Python 3, instead of Python 2, tools/gdb/gdbinit fails as follows:

Traceback (most recent call last):
  File "<string>", line 61, in newobj_handler
  File "<string>", line 35, in load_libcxx_pretty_printers
  File "/usr/lib/python3.5/posixpath.py", line 89, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib/python3.5/genericpath.py", line 145, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components

The reason of the failure is that stdout of subprocess is |byte|, instead of |string|,
and Python 3 doesn't allow mixing strings and bytes in the following |os.path.join|.
We have to convert |byte| to |str| explicitly in Python 3, which is harmless in Python 2.

Change-Id: I5e66be86b61f8e715dc0c2165eb7c427b56d648b
Reviewed-on: https://chromium-review.googlesource.com/c/1338593Reviewed-by: default avatarTakuto Ikuta <tikuta@chromium.org>
Commit-Queue: Hayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608678}
parent cdf490e8
......@@ -34,7 +34,7 @@ def load_libcxx_pretty_printers(compile_dir):
src_dir, _ = git.communicate()
if git.returncode:
return
libcxx_pretty_printers = os.path.join(src_dir.rstrip(), 'third_party',
libcxx_pretty_printers = os.path.join(str(src_dir).rstrip(), 'third_party',
'libcxx-pretty-printers', 'src')
if not os.path.isdir(libcxx_pretty_printers):
return
......
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