Copy list-valued info entries independently in Image.copy() - #9964
Conversation
|
The ubuntu-latest Python 3.13 failure is an X11/Xwayland crash in test_qt_image_qapplication, unrelated to this change (it never touches Qt code). Same environmental flake seen on other unrelated PRs in this repo. |
|
I've created lazerg#3 with suggestions for the tests. |
|
Independently re-verified this fix (not affiliated with the PR, filed the original issue):
|
|
Cherry-picked all three commits from lazerg#3 (e71bb59, 5784152, d9e0e0d), no changes made to them.
Re-verified the consolidated test still catches both halves of the bug: reverting Thanks @tritsystem for the independent verification. |
|
Just a note that IM has now been deprecated. |
ImImagePlugin and IptcImagePlugin both store repeated header/tag values as a list in .info, and Image._new() only shallow-copies the info dict, so a copy shares the same list object as the original. Appending to the copy's list silently mutates the original too, breaking the independence copy() is meant to give you. transform() (and anything routed through it, like a non-90-degree rotate()) had the same shallow copy and the same problem.
Both spots now copy list values individually when building the new info dict, so the resulting images have independent lists. Added regression tests in Tests/test_image_copy.py covering ImImagePlugin, IptcImagePlugin, and transform().
Fixes #9963