Skip to content

Catch urllib3.exceptions.SSLError in Response.iter_content #6056

Description

I believe requests should catch that and raise requests.exceptions.SSLError:

Traceback (most recent call last):
  File "urllib3\response.py", line 438, in _error_catcher
  File "urllib3\response.py", line 519, in read
  File "http\client.py", line 465, in read
  File "socket.py", line 705, in readinto
  File "ssl.py", line 1273, in recv_into
  File "ssl.py", line 1129, in read
ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2536)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tkinter\__init__.py", line 1921, in __call__
  File "tkinter\__init__.py", line 839, in callit
  File "updater_gui.py", line 421, in metadata_cached
  File "concurrent\futures\_base.py", line 438, in result
  File "concurrent\futures\_base.py", line 390, in __get_result
  File "concurrent\futures\thread.py", line 58, in run
  File "updater\updater.py", line 314, in get_metadata
  File "pzd.py", line 256, in get_info
  File "pzd.py", line 216, in _get_central_dir
  File "pzd.py", line 176, in _get_chunk
  File "pzd.py", line 170, in _get_range
  File "requests\models.py", line 836, in content
  File "requests\models.py", line 758, in generate
  File "urllib3\response.py", line 576, in stream
  File "urllib3\response.py", line 512, in read
  File "contextlib.py", line 153, in __exit__
  File "urllib3\response.py", line 449, in _error_catcher
urllib3.exceptions.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2536)

This is requests 2.26.0.

That's some edge case and I've seen that happen only once (this is automatic error report from my program so I don't know any details, it's anonymous). I'm not trying to solve the problem, I just want to be able to catch requests.exceptions.SSLError instead of urllib3.exceptions.SSLError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions