From aed897c9f6b3fbabb57f45f2c6de736baf15a64c Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Mon, 8 Feb 2021 08:26:36 +0100 Subject: [PATCH] Remove use of method_whitelist when possible Deprecated in favor of allowed_methods. Fall back to the old argument for older versions of urllib3 which do not support the new one. Uses conditional attribute check as recommended in https://github.com/urllib3/urllib3/issues/2057 --- firebase_admin/_http_client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/firebase_admin/_http_client.py b/firebase_admin/_http_client.py index f6f0d89fa..ae312095b 100644 --- a/firebase_admin/_http_client.py +++ b/firebase_admin/_http_client.py @@ -22,14 +22,16 @@ from requests.packages.urllib3.util import retry # pylint: disable=import-error -_ANY_METHOD = None - +if hasattr(retry.Retry.DEFAULT, 'allowed_methods'): + _ANY_METHOD = {'allowed_methods': None} +else: + _ANY_METHOD = {'method_whitelist': None} # Default retry configuration: Retries once on low-level connection and socket read errors. # Retries up to 4 times on HTTP 500 and 503 errors, with exponential backoff. Returns the # last response upon exhausting all retries. DEFAULT_RETRY_CONFIG = retry.Retry( - connect=1, read=1, status=4, status_forcelist=[500, 503], method_whitelist=_ANY_METHOD, - raise_on_status=False, backoff_factor=0.5) + connect=1, read=1, status=4, status_forcelist=[500, 503], + raise_on_status=False, backoff_factor=0.5, **_ANY_METHOD) DEFAULT_TIMEOUT_SECONDS = 120