-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix mapped int negative or overflow bugs, improve color C API #2349
Conversation
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.
Overall, I like this pr, makes handling color-like objects easier. Left a few questions.
Also, when we planning to change PG_COLOR_HANDLE_SIMPLE
calls to handle everything?
For whatever reason CircleCI here is trying to build with python 3.6 - which we don't support - so it is failing. |
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.
LGTM 👍
The new API makes sense, and the color tests run locally for me. I also couldn't find any lingering usages of the old ways.
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.
removing code duplication is always good and makes handling colors more consistent.
LGTM
Fix mapped int negative or overflow bugs, improve color C API
The goal of this PR is to fix #2336 and fix #1408 (the original)
The core issues are that a color is actually
Uint32
, butlong
on windows is actuallySint32
. This leads to0x80000000
are casted incorrectly when they areSint32
)0x80000000
The route I'm taking in this PR that involves least user-facing changes and breakages is
In the process, I figured color handling API was in a bit of a mess. We don't handle
str
andint
colors in a lot of places. But in this PR I did not want to change anything that can have a user-facing impact (apart from the bug). This bug is related to issues in the python 2 to 3 port.I introduced unified API for color handling (in a way that doesn't change anything userfacing)
Here is a list of old API, with new API equivalents
pg_RGBAFromColorObj(...)
(now removed) ->pg_RGBAFromObjEx(..., PG_COLOR_HANDLE_SIMPLE)
pg_RGBAFromObj(...)
->pg_RGBAFromObjEx(..., PG_COLOR_HANDLE_SIMPLE)
pg_RGBAFromFuzzyColorObj(...)
(now removed) ->pg_RGBAFromObjEx(..., PG_COLOR_HANDLE_ALL)
A new addition
pg_MappedColorFromObj
replaces copypasted block of code that handled int incorrectly (this is what fixes this bug)The final goal is to get rid of these temporary flags entirely, as every function should handle all
ColorValue
s. But that involves writing more docs and tests, so it's coming in a future PR.