New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise ValueError for io.StringIO in Image.open #4302
Conversation
question.... am I able to use this when calling image.open image.open(b'\x65\x32\x86\x54\xD2\xA1') the byte data is nothing just for example. or does it have to explicitly be. image.open(io.BytesIO(b'\x65\x32\x86\x54\xD2\xA1')) |
@kdschlosser the second one Image.open(io.BytesIO(b'\x65\x32\x86\x54\xD2\xA1')) The first code sample can be used for a path - Image.open(b"Tests/images/hopper.jpg") |
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
the reason I bring that up is because of the error description.. byte literal and bytearray fall into the binary data category.. BytesIO kind of does but fits into the stream or file like object more so then being binary data.. This would be a better description "StringIO is not supported, please use BytesIO instead." just a suggestion.... |
Resolves #4097
The conclusion of discussion in the issue is that StringIO can't be used to pass bytes into Image.open.
A ValueError with a clearer message with now be raised in this situation, explaining that byte data is required instead of StringIO.