-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix some theoretical problems with png reading #5515
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
Conversation
So, if for some reason the read method isn't there (I can't think of a reason why), how does the caller know that something went wrong? |
There's no way to report an error back from a PNG reading callback. However, when the PNG reading is finished, we check https://github.com/matplotlib/matplotlib/blob/master/src/_png.cpp#L576 In this case, the user would get an AttributeError with whatever message |
if (PyBytes_AsStringAndSize(result, &buffer, &bufflen) == 0) { | ||
if (bufflen == (Py_ssize_t)length) { | ||
memcpy(data, buffer, length); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see that now. Now, what if bufflen
does not end up being the same as length
? Are we assuming that an error has been set? Would it make sense for us to set an error if one hasn't been set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. We should probably set an exception in that case. It basically means that it read past the end of the file (which could happen if the file were truncated or something).
Fix some theoretical problems with png reading
Fix some theoretical problems with png reading
back ported to v2.0.x as 3814c77 |
Not 1.5.x (as milestoned)? |
Possible fix fo #5495, but honestly quite theoretical.