add global 'warnings' option (#2762)
This commit is contained in:
@@ -3748,6 +3748,17 @@ Description
|
|||||||
as signal handler for.
|
as signal handler for.
|
||||||
|
|
||||||
|
|
||||||
|
warnings
|
||||||
|
--------
|
||||||
|
Type
|
||||||
|
``string``
|
||||||
|
Default
|
||||||
|
``"default"``
|
||||||
|
Description
|
||||||
|
The `Warnings Filter action <https://docs.python.org/3/library/warnings.html#the-warnings-filter>`__
|
||||||
|
used for (urllib3) warnings.
|
||||||
|
|
||||||
|
|
||||||
pyopenssl
|
pyopenssl
|
||||||
---------
|
---------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -795,12 +795,23 @@ SSL_CIPHERS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
urllib3 = requests.packages.urllib3
|
||||||
|
|
||||||
# detect brotli support
|
# detect brotli support
|
||||||
try:
|
try:
|
||||||
BROTLI = requests.packages.urllib3.response.brotli is not None
|
BROTLI = urllib3.response.brotli is not None
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
BROTLI = False
|
BROTLI = False
|
||||||
|
|
||||||
|
# set (urllib3) warnings filter
|
||||||
|
action = config.get((), "warnings", "default")
|
||||||
|
if action:
|
||||||
|
try:
|
||||||
|
import warnings
|
||||||
|
warnings.simplefilter(action, urllib3.exceptions.HTTPWarning)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
del action
|
||||||
|
|
||||||
# Undo automatic pyOpenSSL injection by requests
|
# Undo automatic pyOpenSSL injection by requests
|
||||||
pyopenssl = config.get((), "pyopenssl", False)
|
pyopenssl = config.get((), "pyopenssl", False)
|
||||||
|
|||||||
Reference in New Issue
Block a user