Skip to content

Fix the test that broke after 3.12 changes to locale.normalize#328

Closed
kkalinowski-reef wants to merge 6 commits into
masterfrom
py312-setlocale
Closed

Fix the test that broke after 3.12 changes to locale.normalize#328
kkalinowski-reef wants to merge 6 commits into
masterfrom
py312-setlocale

Conversation

@kkalinowski-reef
Copy link
Copy Markdown

  • On Linux, C.UTF-8 locale is now part of the standard. macOS and Windows use en_US.UTF-8 instead;
  • Up to 3.11, locale.normalize was converting C.UTF-8 into en_US.UTF-8. If you normalized the locale string, it was impossible to set C.UTF-8;
  • In 3.12, C.UTF-8 maps to itself;
  • gh-74940: Allow fallback to UTF-8 encoding on systems with no locales installed. python/cpython#14925 <– where the change happened;
  • https://peps.python.org/pep-0538/ <– rationale (TL;DR: locale works on duct tape for some time now) ;
  • C.UTF-8 doesn't seem to be used anywhere else in the codebase, except for this one test;
  • Other fix would be to inject a previous value to locale.locale_alias dictionary for certain platforms. However, this is part of the private implementation and could change without prior notice;
  • More changes to the locale are scheduled for 3.15.

- On Linux, C.UTF-8 locale is now part of the standard. macOS and Windows
  use en_US.UTF-8 instead.
- Up to 3.11, `locale.normalize` was converting `C.UTF-8` into `en_US.UTF-8`.
  If you normalized the locale string, it was impossible to set `C.UTF-8`.
- In 3.12, `C.UTF-8` maps to itself.
- python/cpython#14925
- https://peps.python.org/pep-0538/
- `C.UTF-8` doesn't seem to be used anywhere else in the codebase, except for this one test.
- Other fix would be to inject a previous value to `locale.locale_alias` dictionary
  for certain platforms. However, this is part of the private implementation
  and could change without prior notice.
- More changes to the locale are scheduled for 3.15.
@@ -0,0 +1 @@
Fixed tests failing because of changes made to `locale.normalize` in Python 3.12.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik these filenames are supposed to be prepended with + when not refering to issue numbers https://github.com/reef-technologies/b2-sdk-python/blob/master/CONTRIBUTING.md#changelog

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out – I missed that part.

@mjurbanski-reef mjurbanski-reef deleted the py312-setlocale branch December 5, 2023 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants