Translate encoder error codes to strings; deprecate ImageFile.raise_oserror()#7609
Translate encoder error codes to strings; deprecate ImageFile.raise_oserror()#7609radarhere merged 2 commits intopython-pillow:mainfrom
ImageFile.raise_oserror()#7609Conversation
7651a49 to
5426d7b
Compare
|
Should we switch all the internal callers to Alternatively, if we don't want to do that, should we expose the new |
That wouldn't completely simplify things though, would it? Because it is still ideal to raise the error raise _get_oserror(errcode, encoder=True) from excwhich While Pillow values backwards compatibility, I agree that |
5426d7b to
3bb5cf4
Compare
raise_oserror()
|
Sounds good, done. |
3bb5cf4 to
7ede4b5
Compare
When decoding, we use raise_oserror() to convert codec error codes to strings. Adapt that code to be used when encoding as well. Add a new helper function that returns the exception so we can still raise `from exc`.
7ede4b5 to
1df3158
Compare
1df3158 to
3db2e17
Compare
It's only useful if the caller has an IMAGING_CODEC_* error code, which are only produced by codec decode() methods and are automatically translated by ImageFile. Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
3db2e17 to
e1fb1ab
Compare
|
Added @radarhere's changes from bgilbert#4. |
raise_oserror()ImageFile.raise_oserror()
When decoding, we use
raise_oserror()to convert codec error codes to strings. Adapt that code to be used when encoding as well. Add a new helper function that returns the exception so we can still raisefrom exc.Replace all callers of
raise_oserror()withraise _get_oserror(). Deprecateraise_oserror(), since it doesn't need to be in the public API.Split out from #7553 (comment).