diff --git a/src/urllib3/connectionpool.py b/src/urllib3/connectionpool.py index e275a7dbad..7799b9969e 100644 --- a/src/urllib3/connectionpool.py +++ b/src/urllib3/connectionpool.py @@ -1894,7 +1894,8 @@ def urlopen( assert isinstance(response, ResponsePromise) return response # actually a response promise! - assert isinstance(response, HTTPResponse) + if not isinstance(response, HTTPResponse): + warnings.warn(f"Expected {type(response)} to be a subclass of HTTPResponse") if redirect and response.get_redirect_location(): # Handle redirect? diff --git a/src/urllib3/poolmanager.py b/src/urllib3/poolmanager.py index f994287db9..306662bf65 100644 --- a/src/urllib3/poolmanager.py +++ b/src/urllib3/poolmanager.py @@ -914,7 +914,9 @@ def urlopen( # the established connection is not capable of doing multiplexed request kw["multiplexed"] = False - assert isinstance(response, HTTPResponse) + if not isinstance(response, HTTPResponse): + warnings.warn(f"Expected {type(response)} to be a subclass of HTTPResponse") + redirect_location = redirect and response.get_redirect_location() if not redirect_location: return response