pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
939 stars 155 forks source link

Fix handling all color types in `pygame.transform.threshold` #3156

Closed damusss closed 1 month ago

damusss commented 1 month ago

The c internal function _color_from_obj only allows mapped colors for some reason, but all color arguments in the stubs for pygame.transform.threshold pretend to allow ColorLike which also allows strings. My modification makes sure all the promised color types are allowed and add a test to make sure it doesn't break in the future.

pygame.transform.threshold should be the only function using the internal c function because all new api coming for transform is going to use the pygame C api function by default.

damusss commented 1 month ago

It is new behaviour but it wasn't a common and long awaited bugfix like the one about filling with negative topleft area, the c code was just betraying the stubs (someone encountering a value error before this fix should have reported it). Stub-wise, nothing changed, so I think it's not too big of a deal to add a line in the docs. A note in the changelog for 2.5.2 should suffice the people that were using the function anyways.