diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-01-27 21:21:51 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-01-27 22:16:07 +0100 |
commit | c811aba082f55aeb64aaf50a9b70ffb41308af12 (patch) | |
tree | b133220dae378aa94c93e5ef0d669d8bcd5c6bad /src/ukify/ukify.py | |
parent | c8943ce884c3b315aa833a1a9777938719620c6b (diff) | |
download | systemd-c811aba082f55aeb64aaf50a9b70ffb41308af12.tar.gz |
ukify: python 3.9 compat followup
Diffstat (limited to 'src/ukify/ukify.py')
-rwxr-xr-x | src/ukify/ukify.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py index b00b9fd900..5ac4f63fcc 100755 --- a/src/ukify/ukify.py +++ b/src/ukify/ukify.py @@ -440,6 +440,12 @@ def join_initrds(initrds): return b''.join(seq) +def pairwise(iterable): + a, b = itertools.tee(iterable) + next(b, None) + return zip(a, b) + + def pe_validate(filename): import pefile @@ -447,7 +453,7 @@ def pe_validate(filename): sections = sorted(pe.sections, key=lambda s: (s.VirtualAddress, s.Misc_VirtualSize)) - for l, r in itertools.pairwise(sections): + for l, r in pairwise(sections): if l.VirtualAddress + l.Misc_VirtualSize > r.VirtualAddress + r.Misc_VirtualSize: raise ValueError(f'Section "{l.Name.decode()}" ({l.VirtualAddress}, {l.Misc_VirtualSize}) overlaps with section "{r.Name.decode()}" ({r.VirtualAddress}, {r.Misc_VirtualSize})') |