-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Raise an error if ImageDraw co-ordinates are incorrectly ordered #6978
Conversation
6ed94ef
to
1d1c93b
Compare
Shall we use
https://docs.python.org/3/library/exceptions.html#TypeError We're getting a tuple as expected, but of the wrong value order. |
Sure, I've updated my last commit to use ValueError instead. |
I think choosing this approach over just ordering the points isn't a great idea - or at least, not without a major version bump. There are plenty of applications using Pillow that rely on the old behaviour, and the fact that they don't sort their points doesn't necessarily imply that they've got a typo or a bug in their calculations. Maybe sorting would be the better option, with the ordering requirement scheduled for 10.x? |
My main thinking behind this change was trying to help if they do have a bug. I don't know exactly which method is a problem for you, but we've had notes in the ImageDraw documentation that
since 2.3.0, 9 years ago. So I don't think this is a sudden change. If many users say that this is a problem, sure, we can revisit it, but otherwise, I'm reluctant to rollback decisions that we've made. |
Alright, fair enough - 9 years seems like plenty of notice to me. I guess Hyrum's Law applies here. I'll mention for context: the application where I encountered the problem is Overviewer, a Minecraft map viewer with 3.2k stars that recently became unmaintained (hence no official fix and no update to require
which I suspect doesn't hit any of the snags mentioned in the earlier PR because it lacks rounding, outline, or fill. |
Alternative to #6956
For ImageDraw methods that take
(x0, y0, x1, y1)
, raise an error ifx1
<x0
ory0
<y1
.I've also added this requirement to the docs for
rectangle()
androunded_rectangle()
.