Reputation: 1
I have the below line which I assume works in python 2
m = re.search((
# [Nr] Name Type Address Offset
r'^\s*(?P<number>\d+)'
r'\s+(?P<name>[^\s]*)'
r'\s+(?P<size>{hex_re})'
r'\s+(?P<address>{hex_re})'
r'\s+(?P<lma>{hex_re})'
r'\s+(?P<offset>{hex_re})'
r'\s+(?P<align>[^\s]+)'
).format(hex_re=hex_re), line)
On compilation I had the following error -
TypeError: cannot use a string pattern on a bytes-like object
So I tried the following 2 solutions.
br'\s+(?P<name>[^\s]*)'
but then it says byte object does not have format functionbr'\s+(?P<name>[^\s]*)'.decode('utf-8')
. Reiterates the original error.I am trying to get this to run using python3.
Link to exact file: https://github.com/minimalchaos/SM-G970F_a12_kernel/blob/main/scripts/rkp_cfp/instrument.py
line object :
proc = subprocess.Popen([OBJDUMP, '--section-headers', vmlinux], stdout=subprocess.PIPE)
f = each_procline(proc)
it = iter(f)
line = next(it)
Upvotes: 0
Views: 77