py-sdl / py-sdl2

Python ctypes wrapper around SDL2
Other
296 stars 49 forks source link

How to delete UserWarning: Using SDL2 binaries from pysdl2-dll 2.28.0 #264

Closed dimkauzh closed 1 year ago

dimkauzh commented 1 year ago

Hi, so I'm using pysdl2 and pysdl2-dll on mac and everytime I run my code I get this userwarning:

UserWarning: Using SDL2 binaries from pysdl2-dll 2.28.0
a-hurst commented 1 year ago

If you want to hide the warning, all you need to do is suppress warnings when you import PySDL2:

import warnings
with warnings.catch_warnings(): 
    warnings.simplefilter("ignore")
    import sdl2
dimkauzh commented 1 year ago

@a-hurst will it delete all pysdl2 warnings? or only this one?

a-hurst commented 1 year ago

@dimkauzh Only the one that occurs during import! Anything outside of the with warnings.catch_warnings() context will raise errors/warnings like normal.

dimkauzh commented 1 year ago

@dimkauzh Only the one that occurs during import! Anything outside of the with warnings.catch_warnings() context will raise errors/warnings like normal.

But if I get any weird error during import, will it be shown?

a-hurst commented 1 year ago

@dimkauzh If you hit any actual errors/exceptions during import, those will still get raised as usual. The code above only suppresses warnings (i.e. non-fatal messages). If there's an actual problem of some kind importing pysdl2, it'll still throw an exception.

dimkauzh commented 1 year ago

throw

Okay thanks!