ext/image.py fails when passing io.BytesIO object prior to PIL having the opportunity to Image.Open() from it

Issue #83 resolved
Kenneth Long created an issue

When using using PIL, I cannot load an image file from a zipfile object (as is used in sdl2.ext.Resources), The following code produced an AttributeError, _io.BytesIO has no attribute 'encode'

I summarized the following code from my original. I haven't run this exact code in the release PySDL2, though it is how I recall initally finding the issue. I will repro it with the original code if you insist.

Example: in the /dat folder is a a zip archive, the archive contains test.png

import sdl2.ext

RESOURCES = sdl2.ext.Resources(file, "dat") factory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE)

factory.from_image(RESOURCES.get("test.png"))

Fix: ext/image.py ln 47: if hasattr(fname, 'encode'):

prior to byteify (byteify failing leading to inability to load zipfile io.bytesio data stream)

Comments (1)

  1. Log in to comment