ssl - Python warnings filter not catching InsecurePlatformWarning -


since message

lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: insecureplatformwarning: true sslcontext object not available. prevents urllib3 configuring ssl appropriately , may cause ssl connections fail. more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. insecureplatformwarning

has been flooding logs (yes, know important, fix real problem eventually! promise!), want add filter have show once. added this:

warnings.simplefilter(action='once', category=insecureplatformwarning, append=true) 

but doesn't filter anything. when this:

warnings.simplefilter(action='once', append=true) 

it warnings, not want, shows code indeed being executed , filter work.

what doing wrong in terms of category? don't want disable warnings. want make specific warning show once now.

thanks!

try removing append=true:

warnings.simplefilter(action='once', category=insecureplatformwarning) 

the urllib3 code already has default logging configuration. if use append=true, default configuration overrides yours.


Comments