[SeaBIOS] [PATCH] Make scripts compatible with Python 2 and 3

Johannes Krampf johannes.krampf at googlemail.com
Sat Jan 18 11:45:47 CET 2014


Hello,

here you go. Sorry it took me so long to get back to you, I had to 
extend my git knowledge first and do some reading of the man pages for 
git-am and git-format-patch. And thanks for splitting the patch, I 
should have done so myself.

Regarding the bytes/string change: Some things are simply binary data 
(i.e. null padding) and there is not much which could be done 
differently. If we did not care about older distributions, then using a 
bytes literal (b"\0") instead of my as_bytes-replacement 
(as_bytes("\0")) would be nicer, but is only available starting with 
Python 2.6.

All the object dump parsing code in checkrom.py and layoutrom.py should 
only deal with ASCII input. Changing this to strings would probably slim 
down the patch considerably since most other changes which transform 
literals to bytes are caused by reading bytes and comparing them with 
these literals.

I'll take a look at this and send you a revised patch for the 
string/bytes change. The first 4 patches seem fine to me.

- Johannes

On 01/12/2014 05:49 PM, Kevin O'Connor wrote:
> On Sun, Jan 12, 2014 at 11:51:01AM +0100, Johannes Krampf wrote:
>> Hello SeaBIOS developers,
>>
>> I've created a new patch which allows me to build SeaBIOS
>> successfully with both Python 2 and Python 3. (Tested with qemu)
>
> Thanks.  I broke up your patches to make them easier to discuss (see
> attached).  Can you provide a "Signed-off-by" for them?
>
>>
>> Aside from print statements/functions, str/bytes and integer
>> division for Python 2/3 compatibility, I also did some small changes
>> (removing semicolons) to the acpi_* files to reduce the noise from
>> pylint output.
>
> I'm uncomfortable with the as_bytes/as_str change.  I wonder if there
> is a way to avoid all the conversions by changing all the symbols to
> strings up front, or by just reading/writing the files in ascii mode
> instead of binary mode.
>
>>
>> I was careful not to break the code, but I could not test the
>> readserial script lacking the necessary hardware and would
>> appreciate if someone else could give it a try.
>>
>> All of my changes should work with Python 2.4 and newer (version in
>> RHEL 5, the oldest supported version). If you require compatibility
>> with older Python versions, please tell me and I will revise the
>> patch.
>
> -Kevin
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-build-Remove-unneccesary-semicolons-from-acpi_extrac.patch
Type: text/x-patch
Size: 8397 bytes
Desc: not available
URL: <http://www.seabios.org/pipermail/seabios/attachments/20140118/a174f329/attachment-0005.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-build-Make-print-statements-in-scripts-python3-compa.patch
Type: text/x-patch
Size: 9643 bytes
Desc: not available
URL: <http://www.seabios.org/pipermail/seabios/attachments/20140118/a174f329/attachment-0006.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-build-Be-explicit-that-we-want-integers-when-dividin.patch
Type: text/x-patch
Size: 2593 bytes
Desc: not available
URL: <http://www.seabios.org/pipermail/seabios/attachments/20140118/a174f329/attachment-0007.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-build-Avoid-sort-on-unordered-classes-for-python3-co.patch
Type: text/x-patch
Size: 1898 bytes
Desc: not available
URL: <http://www.seabios.org/pipermail/seabios/attachments/20140118/a174f329/attachment-0008.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-build-Be-careful-with-unicode-and-byte-strings-for-p.patch
Type: text/x-patch
Size: 30016 bytes
Desc: not available
URL: <http://www.seabios.org/pipermail/seabios/attachments/20140118/a174f329/attachment-0009.patch>


More information about the SeaBIOS mailing list