Decode bytes when formatting them as strings
authorSpencer Nelson <swnelson@uw.edu>
Fri, 11 Jun 2021 19:07:02 +0000 (12:07 -0700)
committeryonghong-song <ys114321@gmail.com>
Wed, 16 Jun 2021 02:10:08 +0000 (19:10 -0700)
commitdc1bceb8c891069745517cb2b444a8c4853e71ce
treea530f87b09ca7901a6dd2052fcf29a3386dc49f5
parent88ca3305c94e8bc383556085949c7b35eb27b2db
Decode bytes when formatting them as strings

USDTProbe objects (and USDTProbeArguments and USDTProbeLocations) are
instantiated with data that's sourced from libccc calls. That means
that their attributes are bytes-typed, not string-typed.

When a bytes-typed value is rendered into a string with Python's '%s'
formatting directive, it gets a wrapped in single quotes and prefixed
with b. For example, b'probe-location'. This is visually noisy, but
also breaks some tool behavior which uses string-formatted values for
stuff like filters.

This is only an issue in Python 3. In Python 2, the bytes type is just
an alias for the string type, and so byte sequences from libcc were
implicitly decoded as ASCII text.
src/python/bcc/usdt.py
tools/tplist.py