Skip to content

Commit

Permalink
Merge branch 'master' into towncrier_checker_for_nox
Browse files Browse the repository at this point in the history
* master:
  Fix the test that broke after 3.12 changes to `locale.normalize` (Backblaze#452)
  fix changelog items prefix
  use proper exception class
  fix: provide error message for mismatching upload size options
  • Loading branch information
kkalinowski-reef committed Dec 6, 2023
2 parents 2acae69 + e0edd22 commit bb4ed01
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ jobs:
python-version: "pypy-3.10"
- os: "windows-latest"
python-version: "pypy-3.10"
# TODO: 3.12 setlocale(...) is broken on Windows & Mac
- os: "macos-latest"
python-version: "3.12"
- os: "windows-latest"
python-version: "3.12"
steps:
- uses: actions/checkout@v3
with:
Expand Down
10 changes: 9 additions & 1 deletion b2sdk/transfer/emerge/planner/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from collections import deque
from math import ceil

from b2sdk.exception import InvalidUserInput
from b2sdk.http_constants import (
DEFAULT_MAX_PART_SIZE,
DEFAULT_MIN_PART_SIZE,
Expand Down Expand Up @@ -94,7 +95,14 @@ def __init__(
self.min_part_size = min_part_size or DEFAULT_MIN_PART_SIZE
self.recommended_upload_part_size = recommended_upload_part_size or DEFAULT_RECOMMENDED_UPLOAD_PART_SIZE
self.max_part_size = max_part_size or DEFAULT_MAX_PART_SIZE
assert self.min_part_size <= self.recommended_upload_part_size <= self.max_part_size
if self.min_part_size > self.recommended_upload_part_size:
raise InvalidUserInput(
f"min_part_size value ({self.min_part_size}) exceeding recommended_upload_part_size value ({self.recommended_upload_part_size})"
)
if self.recommended_upload_part_size > self.max_part_size:
raise InvalidUserInput(
f"recommended_upload_part_size value ({self.recommended_upload_part_size}) exceeding max_part_size value ({self.max_part_size})"
)

@classmethod
def from_account_info(
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+py312-setlocale-fail.infrastructure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed tests failing because of changes made to `locale.normalize` in Python 3.12.
1 change: 1 addition & 0 deletions changelog.d/+upload-check-replace-assert.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace blank `assert` with exception when size values for parts upload are misaligned.
File renamed without changes.
9 changes: 6 additions & 3 deletions test/unit/b2http/test_b2http.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import datetime
import locale
import sys
from unittest.mock import MagicMock, call, patch

import apiver_deps
Expand Down Expand Up @@ -306,9 +307,11 @@ class TestB2HttpUserAgentAppend(TestB2Http):

class TestSetLocaleContextManager(TestBase):
def test_set_locale_context_manager(self):
test_locale = locale.normalize(
'C.utf8'
) # C.UTF-8 on Ubuntu 18.04 Bionic, C.utf8 on Ubuntu 22.04 Jammy
# C.UTF-8 on Ubuntu 18.04 Bionic, C.utf8 on Ubuntu 22.04 Jammy
# Neither macOS nor Windows have C.UTF-8 locale, and they use `en_US.UTF-8`.
# Since Python 3.12, locale.normalize no longer falls back
# to the `en_US` version, so we're providing it here manually.
test_locale = locale.normalize('C.UTF-8' if sys.platform == 'linux' else 'en_US.UTF-8')
other_locale = 'C'

saved = locale.setlocale(locale.LC_ALL)
Expand Down

0 comments on commit bb4ed01

Please sign in to comment.