-
-
Notifications
You must be signed in to change notification settings - Fork 183
Implementing warnings system and pygame.debug #2944
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
base: main
Are you sure you want to change the base?
Conversation
Update outputted warning in docs to reflect changes.
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.
Everything in the side of documentation seems fine. Maybe if you add a code example that makes full use of the function argument, it would be more helpful to users.
Hello, thanks for looking at this. This is a complex patch, and I don't really see what adding a pygame-ce specific paradigm of filtering our existing warnings does for us. I did not anticipate pygame.debug changing any existing warnings. It instead would add a whole new category of more opiniated ones and extra information. Maybe it could use SDL_Log and change the SDL log level so we get SDL debug information too? But then again maybe the juice isn't worth the squeeze for this. |
Well, this is a large patch, but it isn't complex - the logic behind it is quite simple, there are just a lot of places that needed to be updated to use the new warnings system (just renaming the Why I'm using what I'm using and not something like SDL warnings which have urgency? Because python warnings system was already used in the code base and I think that benefits that come from using python warnings system outweighs those of SDL warnings system (seamless integration with python code, advanced filtering system supporting regex, unit testing, etc...). An alternative implementation could create multiple filtering rules to ignore given warnings, but it would be slower (warnings that wouldn't be shown, would still need to go through the python warnings system) and harder to maintain (the necessity to keep the filter lists and updating them when a warning is added/removed/changed), so I think this is near optimal solution. That's my opinion on this matters.
|
Sure, but why do we need a new warnings system? |
This PR warnings system can be summarized as (omitting code for formatting warning message to include warning level): static int
pgWarn(PyObject *category, const char *message, Py_ssize_t stack_level,
int urgency)
{
if (pg_warn_filter < urgency)
return 0;
return PyErr_WarnEx(category, message, stack_level);
} I used incorrect wording there - this is not much "a new warnings system", but rather a thin wrapper around an existing one (and heavily used before). |
But Myre is proposing adding a new warning there, not changing existing warnings to not trigger. |
Fair point, I'd like to hear your opinion on the warnings level I set for them (I've split warnings between 0, 1 and 2, where 0 and 1 are by default enabled with the intention of possibility introducing something like |
Fixes #2894
Notes
(mostly to self):pygame.base.get_warnings_filter
/pygame.base.set_warnings_filter
be public API (likely not)?