Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ upcoming release can be found in [changelog.d](changelog.d).

<!-- towncrier release notes start -->

## [2.8.1](https://github.com/Backblaze/b2-sdk-python/releases/tag/v2.8.1) - 2025-04-24


### Fixed

- Fix TimeoutError handling in `b2http`.

### Doc

- Document params in FileRetentionSetting class. ([#532](https://github.com/Backblaze/b2-sdk-python/issues/532))


## [2.8.0](https://github.com/Backblaze/b2-sdk-python/releases/tag/v2.8.0) - 2025-01-23


Expand Down
6 changes: 4 additions & 2 deletions b2sdk/_internal/b2http.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,16 @@ def _translate_errors(cls, fcn, post_params=None):
raise UnknownHost()
elif isinstance(e1, requests.packages.urllib3.exceptions.ProtocolError):
e2 = e1.args[1]

if isinstance(e2, TimeoutError):
raise B2RequestTimeout(str(e0))

if isinstance(e2, socket.error):
if len(e2.args) >= 2 and e2.args[1] == 'Broken pipe':
# Broken pipes are usually caused by the service rejecting
# an upload request for cause, so we use a 400 Bad Request
# code.
raise BrokenPipe()
elif isinstance(e2, TimeoutError):
raise B2RequestTimeout(str(e0))
raise B2ConnectionError(str(e0))

except requests.Timeout as e:
Expand Down
1 change: 0 additions & 1 deletion changelog.d/532.doc.md

This file was deleted.

12 changes: 12 additions & 0 deletions test/unit/b2http/test_b2http.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from apiver_deps import USER_AGENT, B2Http, B2HttpApiConfig, ClockSkewHook
from apiver_deps_exception import (
B2ConnectionError,
B2RequestTimeout,
BadDateFormat,
BadJson,
BadRequest,
Expand Down Expand Up @@ -80,6 +81,17 @@ def fcn():
with pytest.raises(UnknownHost):
B2Http._translate_errors(fcn)

def test_request_timeout(self):
def fcn():
raise requests.ConnectionError(
requests.packages.urllib3.exceptions.ProtocolError(
'dummy', TimeoutError('The write operation timed out')
)
)

with pytest.raises(B2RequestTimeout):
B2Http._translate_errors(fcn)

def test_connection_error(self):
def fcn():
raise requests.ConnectionError('a message')
Expand Down
Loading