File nml-0.4.2-pillow.diff of Package nml

diff -ur nml-0.4.2/nml/spriteencoder.py nml-0.4.2_fix/nml/spriteencoder.py
--- nml-0.4.2/nml/spriteencoder.py	2015-09-12 20:46:39.000000000 +0200
+++ nml-0.4.2_fix/nml/spriteencoder.py	2015-11-15 14:09:46.774656565 +0100
@@ -276,7 +276,10 @@
                 pos = generic.build_position(sprite_info.poslist)
                 raise generic.ScriptError("Read beyond bounds of image file '{}'".format(filename_32bpp.value), pos)
             sprite = im.crop((x, y, x + size_x, y + size_y))
-            rgb_sprite_data = sprite.tostring()
+            # tostring is deprecated, replaced by tobytes in Pillow (PIL fork)
+            # (1.1.7) PIL still uses it
+            sprite_data_fn = getattr(sprite, "tobytes", getattr(sprite, "tostring"))
+            rgb_sprite_data = sprite_data_fn()
 
             if (info_byte & INFO_ALPHA) != 0:
                 # Check for half-transparent pixels (not valid for ground sprites)
@@ -296,7 +299,10 @@
                 raise generic.ScriptError("Read beyond bounds of image file '{}'".format(filename_8bpp.value), pos)
             mask_sprite = mask_im.crop((mask_x, mask_y, mask_x + size_x, mask_y + size_y))
 
-            mask_sprite_data = self.palconvert(mask_sprite.tostring(), im_mask_pal)
+            # tostring is deprecated, replaced by tobytes in Pillow (PIL fork)
+            # (1.1.7) PIL still uses it
+            mask_sprite_data_fn = getattr(mask_sprite, "tobytes", getattr(mask_sprite, "tostring"))
+            mask_sprite_data = self.palconvert(mask_sprite_data_fn(), im_mask_pal)
 
             # Check for white pixels; those that cause "artefacts" when shading
             pixel_stats['white'] = sum(p == 255 for p in mask_sprite_data)
openSUSE Build Service is sponsored by