minima1cha0s
minima1cha0s

Reputation: 1

Porting python2 to python3

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.

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

Answers (0)

Related Questions