scripts/signrom: remove Python 2 support, add shebang
PATCH 1/1 scripts/signrom: remove Python 2 support, add shebang
Based-on: <[email protected]>
--- scripts/signrom.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
scripts/signrom.py +4 -8
@@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + from __future__ import print_function # # Option ROM signing utility
@@ -44,14 +46,8 @@ fout.write(data) checksum = 0 for b in data: - # catch Python 2 vs. 3 differences - if isinstance(b, int): - checksum += b - else: - checksum += ord(b) -checksum = (256 - checksum) % 256 - -# Python 3 no longer allows chr(checksum) + checksum = (checksum - b) & 255 + fout.write(struct.pack('B', checksum)) fin.close()
Signature · 1 line
2.21.0
Quoted 25 lines · Paolo Bonzini
Based-on: <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- scripts/signrom.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)scripts/signrom.py +2
-3@@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + from __future__ import print_function # # Option ROM signing utility@@ -44,14 +46,8 @@ fout.write(data) checksum = 0 for b in data: - # catch Python 2 vs. 3 differences - if isinstance(b, int): - checksum += b
scripts/signrom.py fout.write(data) · line 53
Quoted 10 lines
scripts/signrom.py +2
-5- else: - checksum += ord(b) -checksum = (256 - checksum) % 256 - -# Python 3 no longer allows chr(checksum) + checksum = (checksum - b) & 255 + fout.write(struct.pack('B', checksum)) fin.close()
Also, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Paolo Bonzini
Based-on: <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
scripts/signrom.py| 12 ++++--------1 file changed, 4 insertions(+), 8 deletions(-)scripts/signrom.py +2
-0@@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +from
__future__importprint_function
#
# Option ROM signing utilityscripts/signrom.py +0
-0@@ -44,14 +46,8 @@ fout.write(data)checksum = 0
for b in data:
- # catch Python 2 vs. 3 differences
- ifisinstance(b, int):
- checksum += b
- else:
- checksum += ord(b)scripts/signrom.py +2
-3-checksum = (256 - checksum) % 256 - -# Python 3 no longer allows chr(checksum) + checksum = (checksum - b) & 255 +Quoted 3 lines
fout.write(struct.pack('B', checksum))
fin.close()Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 2 lines
Also, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next
Oh, good. So I've unqueued your series on which this is based.
Paolo
Quoted 38 lines · Paolo Bonzini
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 23 lines · Paolo Bonzini
Based-on: <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- scripts/signrom.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)scripts/signrom.py +2
-3@@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + from __future__ import print_function # # Option ROM signing utility@@ -44,14 +46,8 @@ fout.write(data) checksum = 0 for b in data: - # catch Python 2 vs. 3 differences - if isinstance(b, int): - checksum += bscripts/signrom.py fout.write(data) · line 52
Quoted 10 lines
scripts/signrom.py +2
-5- else: - checksum += ord(b) -checksum = (256 - checksum) % 256 - -# Python 3 no longer allows chr(checksum) + checksum = (checksum - b) & 255 + fout.write(struct.pack('B', checksum)) fin.close()Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 4 lines
Quoted 2 lines
Also, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-nextOh, good. So I've unqueued your series on which this is based.
Aargh I received your "series queued" mail _after_ this patch.
As you prefer, but I have various python patches pending already. If I keep "Explicit usage of Python 3" do you mind Acking it?
Thanks!
Phil.
Paolo Bonzini
Acked-byQuoted 7 lines · Philippe Mathieu-Daudé
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Also, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next
Quoted 6 lines
Quoted 1 line
Oh, good. So I've unqueued your series on which this is based.
Aargh I received your "series queued" mail _after_ this patch.
As you prefer, but I have various python patches pending already. If I keep "Explicit usage of Python 3" do you mind Acking it?
Sure, the least patches I queue the better.
Paolo