Partially resolve #257: video_test #270
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
This brings py-sdl2 a bit closer to fully resolving #257, by reducing the number of places where it assumes
SDL_GetError != ''
implies that there was an error. #267, #269, etc. are targeted versions of this addressing places where a newer SDL2 release does break that assumption, whereas this PR is a preventative version addressing places where a newer SDL2 release might break that assumption but has not done so yet.This PR only covers
video_test
, treating all other tests as out-of-scope. Many other test modules will eventually need a change similar to this one.video_test: Don't check error unless a function failed
Helps: Incorrect use of SDL_GetError() to check whether calls failed #257
video_test: Use _check_error_msg() a bit more often
video_test: Mitigate unsuitability of SDL_GetError() for detecting failure
SDL_GetError() is like errno: it's documented not to be suitable for
detecting failure, only for getting more details if failure was already
detected (its result is unspecified on success, because a successful
API call might have been implemented by doing something that failed,
detecting that, and falling back to doing something different).
However, some functions in SDL2 return void, so we have no other way
to tell whether they have failed (they do return a result in SDL3).
To make it less likely that upgrading SDL2 will make these tests regress,
clear the error indicator immediately before calling the function under
test. It is still not guaranteed to be empty on success, but at least
this way we make sure it doesn't already contain an error message from
a previous function call.
Helps: Incorrect use of SDL_GetError() to check whether calls failed #257
Merge Checklist
closes #<issue-number>
to automatically close an issue