Make png2c.py work with Python 3.9+

array.tostring() was removed in 3.9, so use tobytes() instead.

This makes the script incompatible with Python 2, but this shouldn't be
much of a concern any more these days.
This commit is contained in:
Vadim Zeitlin 2023-04-27 18:17:11 +02:00
parent d43b2862c3
commit a958683071

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python
# This script is a slightly modified version of the original found at
#
@ -50,7 +50,7 @@ for path in sys.argv[1:]:
# Each PNG file starts with a 8 byte signature that should be followed
# by IHDR chunk which is always 13 bytes in length so the first 16
# bytes are fixed (or at least we expect them to be).
if bytes[0:16].tostring() != b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR':
if bytes[0:16].tobytes() != b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR':
print('"%s" doesn\'t seem to be a valid PNG file.' % filename)
continue