fix: urllib3.__version__ may not have a patch number

fix https://github.com/MISP/PyMISP/issues/698
pull/700/head
Raphaël Vinot 2021-02-15 12:00:06 +01:00
parent c280ea146d
commit e52263b75a
1 changed files with 6 additions and 1 deletions

View File

@ -94,7 +94,12 @@ def brotli_supported() -> bool:
"""
# urllib >= 1.25.1 includes brotli support
major, minor, patch = urllib3.__version__.split('.') # noqa: F811
version_splitted = urllib3.__version__.split('.') # noqa: F811
if len(version_splitted) == 2:
major, minor = version_splitted
patch = 0
else:
major, minor, patch = version_splitted
major, minor, patch = int(major), int(minor), int(patch)
urllib3_with_brotli = (major == 1 and ((minor == 25 and patch >= 1) or (minor >= 26))) or major >= 2