common: drop locale setting hack #36524

Manually merged
fanquake merged 3 commits from drop_locale_hacks into master 2026-10-19 08:00:58 +00:00 AGit
fanquake commented 2026-10-14 07:31:09 +00:00 (Migrated from github.com)

This was added to work around boost::filesystem throwing when the environments locale was invalid. Boost.Filesystem has been removed, and std::filesystem doesn't use the locale on POSIX (and bitcoind never calls setlocale).

Qt calls setlocale(LC_ALL, "") on startup, and falls back to C.UTF-8 if the locale isn't UTF-8.

Alternative to #36399, which extends the hack further.

This was added to work around `boost::filesystem` throwing when the environments locale was invalid. Boost.Filesystem has been removed, and `std::filesystem` doesn't use the locale on POSIX (and bitcoind never calls `setlocale`). Qt calls `setlocale(LC_ALL, "")` on startup, and falls back to `C.UTF-8` if the locale isn't `UTF-8`. Alternative to #36399, which extends the hack further.
DrahtBot commented 2026-10-14 07:31:18 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK maflcko, stickies-v, sedited

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36524 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36524.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36524#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [maflcko](https://github.com/bitcoin/bitcoin/pull/36524#issuecomment-6210762734), [stickies-v](https://github.com/bitcoin/bitcoin/pull/36524#issuecomment-6210877823), [sedited](https://github.com/bitcoin/bitcoin/pull/36524#pullrequestreview-5568464168) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: cce32b16874e85e8a00cfa1a2190f0b6f4dcaf66
Head: 43bb5e3c467f38566f7d7271b0030ef4af1cf78c

I found no actionable issues in this static review.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `cce32b16874e85e8a00cfa1a2190f0b6f4dcaf66` Head: `43bb5e3c467f38566f7d7271b0030ef4af1cf78c` I found no actionable issues in this static review. [Full review report](<https://review.fish.foo/traces/36524-43bb5e3c467f38566f7d7271b0030ef4af1cf78c-824-4.html>)
maflcko commented 2026-10-14 07:42:12 +00:00 (Migrated from github.com)

Qt calls setlocale(LC_ALL, "") on startup, and falls back to C.UTF-8 if the locale isn't UTF-8.

Can you add a reference/source to this claim?

> Qt calls `setlocale(LC_ALL, "")` on startup, and falls back to `C.UTF-8` if the locale isn't `UTF-8`. Can you add a reference/source to this claim?
fanquake commented 2026-10-14 07:48:59 +00:00 (Migrated from github.com)
> Can you add a reference/source to this claim? https://github.com/qt/qtbase/blob/37a9bf670e422daa20c1806fc873c27b35fb287d/src/corelib/kernel/qcoreapplication.cpp#L571-L639 We also claim this in: https://github.com/bitcoin/bitcoin/blob/60ebd98c79043e99c582bcbaf412bc424c8daf9b/src/qt/bitcoin.cpp#L203
maflcko commented 2026-10-14 08:20:45 +00:00 (Migrated from github.com)

lgtm ACK 622df9e941

lgtm ACK 622df9e941dd55fc9b01125ea1de659ed6a9794e
sedited (Migrated from github.com) approved these changes 2026-10-14 08:56:40 +00:00
sedited (Migrated from github.com) left a comment
ACK 622df9e941dd55fc9b01125ea1de659ed6a9794e
hebasto (Migrated from github.com) reviewed 2026-10-14 14:16:04 +00:00
hebasto (Migrated from github.com) left a comment

Doesn’t this change affect the behaviour of the scripts specified via the -*notify options in environments where the locale is invalid?

Doesn’t this change affect the behaviour of the scripts specified via the `-*notify` options in environments where the locale is invalid?
maflcko commented 2026-10-14 14:24:21 +00:00 (Migrated from github.com)

Yes, that is also what Ralph says (#36524) , but I think users are better off not setting an invalid locale. If they really want to set an invalid locale, they are better off setting the locale in their notify script explicitly. (Explicitly setting it works before and after the changes here)

Yes, that is also what Ralph says (https://git.fish.foo/bitcoin/bitcoin/pulls/36524#author-ralph) , but I think users are better off not setting an invalid locale. If they really want to set an invalid locale, they are better off setting the locale in their notify script explicitly. (Explicitly setting it works before and after the changes here)
stickies-v (Migrated from github.com) reviewed 2026-10-14 15:47:57 +00:00
stickies-v (Migrated from github.com) left a comment

Concept ACK

This surfaces an already buggy test, that now fails on some local environments, see comment.

Concept ACK This surfaces an already buggy test, that now fails on some local environments, see comment.
stickies-v (Migrated from github.com) commented 2026-10-14 15:46:45 +00:00

This surfaces a bug in interface_gui.py, that passes on master but fails on 622df9e941.

On CI, we set LC_ALL=C.UTF-8 in all scripts, so the locale is set in all tests, which means that we're not really testing this change.

When running this test locally on a Linux environment with LC_ALL unset and no nl_NL.UTF-8 locale installed, the interface_gui.py test fails. This is because in test_node.py:302, we set subp_env.setdefault("LC_ALL", "nl_NL.UTF-8"). On CI, this operation is a no-op because LC_ALL is always set, so the nl_NL.UTF-8 locale is never actually set. When it is actually set, and nl_NL.UTF-8 isn't installed on the machine, the test fails.

Tested in a debian:trixie container:

$ python3 build/test/functional/interface_gui.py

...
  2026-10-14T14:57:03.224515Z TestFramework (INFO): PRNG seed is: 6521282163018713296
  2026-10-14T14:57:03.276866Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_nr9vej0d
  2026-10-14T14:57:03.871440Z TestFramework (INFO): Test that bitcoin-gui starts up and can be stopped via RPC
  2026-10-14T14:57:04.243870Z TestFramework (ERROR): Unexpected exception:
  Traceback (most recent call last):
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_framework.py", line 146, in main
      self.run_test()
      ~~~~~~~~~~~~~^^
    File "/Users/stickies-v/code/bitcoin/review/36524/build/test/functional/interface_gui.py", line 34, in run_test
      self.stop_node(0)
      ~~~~~~~~~~~~~~^^^
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_framework.py", line 527, in stop_node
      self.nodes[i].stop_node(expected_stderr, wait=wait)
      ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 517, in stop_node
      self.wait_until_stopped(expected_stderr=expected_stderr)
      ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 563, in wait_until_stopped
      self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout)
      ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 913, in wait_until
      return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.timeout_factor, check_interval=check_interval)
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/util.py", line 449, in wait_until_helper_internal
      if predicate():
         ~~~~~~~~~^
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 563, in <lambda>
      self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout)
                              ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
    File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 548, in is_node_stopped
      raise AssertionError("Unexpected stderr {} != {}".format(stderr, expected_stderr))
  AssertionError: Unexpected stderr Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
  Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
  If this causes problems, reconfigure your locale. See the locale(1) manual
  for more information.

The test runs fine with LC_ALL=C.UTF-8 python3 build/test/functional/interface_gui.py.

From #35551, it seems like we set a well-translated language to ensure that in a foreign locale, RPC strings still come through in English. If that's what we want to achieve, then perhaps we could e.g. add github.com/stickies-v/bitcoin@a39fa5420e as a minimal fix prior to this change?

This surfaces a bug in `interface_gui.py`, that passes on `master` but fails on 622df9e941dd55fc9b01125ea1de659ed6a9794e. On CI, we set `LC_ALL=C.UTF-8` in all scripts, so the locale is set in all tests, which means that we're not really testing this change. When running this test locally on a Linux environment with `LC_ALL` unset and no `nl_NL.UTF-8` locale installed, the `interface_gui.py` test fails. This is because in `test_node.py:302`, we set `subp_env.setdefault("LC_ALL", "nl_NL.UTF-8")`. On CI, this operation is a no-op because `LC_ALL` is always set, so the `nl_NL.UTF-8` locale is never actually set. When it is actually set, and `nl_NL.UTF-8` isn't installed on the machine, the test fails. Tested in a `debian:trixie` container: ``` $ python3 build/test/functional/interface_gui.py ... 2026-10-14T14:57:03.224515Z TestFramework (INFO): PRNG seed is: 6521282163018713296 2026-10-14T14:57:03.276866Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_nr9vej0d 2026-10-14T14:57:03.871440Z TestFramework (INFO): Test that bitcoin-gui starts up and can be stopped via RPC 2026-10-14T14:57:04.243870Z TestFramework (ERROR): Unexpected exception: Traceback (most recent call last): File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_framework.py", line 146, in main self.run_test() ~~~~~~~~~~~~~^^ File "/Users/stickies-v/code/bitcoin/review/36524/build/test/functional/interface_gui.py", line 34, in run_test self.stop_node(0) ~~~~~~~~~~~~~~^^^ File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_framework.py", line 527, in stop_node self.nodes[i].stop_node(expected_stderr, wait=wait) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 517, in stop_node self.wait_until_stopped(expected_stderr=expected_stderr) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 563, in wait_until_stopped self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 913, in wait_until return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.timeout_factor, check_interval=check_interval) File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/util.py", line 449, in wait_until_helper_internal if predicate(): ~~~~~~~~~^ File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 563, in <lambda> self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout) ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 548, in is_node_stopped raise AssertionError("Unexpected stderr {} != {}".format(stderr, expected_stderr)) AssertionError: Unexpected stderr Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8. Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead. If this causes problems, reconfigure your locale. See the locale(1) manual for more information. ``` The test runs fine with `LC_ALL=C.UTF-8 python3 build/test/functional/interface_gui.py`. From #35551, it seems like we set a well-translated language to ensure that in a foreign locale, RPC strings still come through in English. If that's what we want to achieve, then perhaps we could e.g. add https://github.com/stickies-v/bitcoin/commit/a39fa5420ed965f8975221ce49bd813fac3aed61 as a minimal fix prior to this change?
fanquake commented 2026-10-14 17:01:03 +00:00 (Migrated from github.com)

Doesn’t this change affect the behaviour of the scripts specified via the -*notify options in environments where the locale is invalid?

Could you make a specific comment, instead of a vague LLM generated one?

> Doesn’t this change affect the behaviour of the scripts specified via the -*notify options in environments where the locale is invalid? Could you make a specific comment, instead of a vague LLM generated one?
fanquake (Migrated from github.com) reviewed 2026-10-15 02:38:06 +00:00
fanquake (Migrated from github.com) commented 2026-10-15 02:38:06 +00:00

I'm not completely sure what the expectations are with this test, but I've cherry-picked your commit here.

I'm not completely sure what the expectations are with this test, but I've cherry-picked your commit here.
maflcko commented 2026-10-15 06:30:45 +00:00 (Migrated from github.com)

Only change is a gui test fixup.

review ACK 27be7413e8 🚇

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 27be7413e82072e8e68b958e808bbee379f4ac15 🚇
zmTJxrqt5CAm6rIQ+TMaGY6wW+CucsSb5e19C8wSwr0yqL18TX53qz6OFVwumCGNyfHrBbGmMx16i1yiR0xADw==
Only change is a gui test fixup. review ACK 27be7413e82072e8e68b958e808bbee379f4ac15 🚇 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: review ACK 27be7413e82072e8e68b958e808bbee379f4ac15 🚇 zmTJxrqt5CAm6rIQ+TMaGY6wW+CucsSb5e19C8wSwr0yqL18TX53qz6OFVwumCGNyfHrBbGmMx16i1yiR0xADw== ``` </details>
maflcko commented 2026-10-15 06:45:27 +00:00 (Migrated from github.com)

I mean if people feel strongly, there could be a release note along the lines:

The UTF-8 fallback for invalid or unavailable environment locales has been removed. Affected -*notify scripts may explicitly set a valid locale, such as LC_ALL=C.UTF-8, if needed.

I mean if people feel strongly, there could be a release note along the lines: `The UTF-8 fallback for invalid or unavailable environment locales has been removed. Affected -*notify scripts may explicitly set a valid locale, such as LC_ALL=C.UTF-8, if needed.`
stickies-v (Migrated from github.com) reviewed 2026-10-15 09:40:48 +00:00
stickies-v (Migrated from github.com) commented 2026-10-15 09:40:48 +00:00

From https://github.com/bitcoin/bitcoin/pull/35551#discussion_r3433473219:

Could also set something like LC_ALL=nl_NL.UTF-8 to check the RPC response is not translated by accident?

From https://github.com/bitcoin/bitcoin/pull/35551#discussion_r3433473219: > Could also set something like `LC_ALL=nl_NL.UTF-8` to check the RPC response is not translated by accident?
stickies-v commented 2026-10-15 09:43:57 +00:00 (Migrated from github.com)

ACK 27be7413e8

I mean if people feel strongly, there could be a release note along the lines:

I actually think that would be good. Shouldn't affect many people, but probably some, and having a mention in the release notes may save them a lot of confusion. Your proposed text works well for me.

ACK 27be7413e82072e8e68b958e808bbee379f4ac15 > I mean if people feel strongly, there could be a release note along the lines: I actually think that would be good. Shouldn't affect many people, but probably some, and having a mention in the release notes may save them a lot of confusion. Your proposed text works well for me.
fanquake commented 2026-10-16 01:05:45 +00:00 (Migrated from github.com)

Added a release note.

Added a release note.
maflcko commented 2026-10-16 07:51:27 +00:00 (Migrated from github.com)

review ACK 43bb5e3c46 🚂

Show signature

Signature:

untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
trusted comment: review ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c 🚂
0RN8toZudX3WfXDZvsUbFkOd9P5Kd1le5Ef2zAGNlR9jHQMC0uLLAW10sHCvqSo5XvCP6+k/ZD/wjaINsvKADA==
review ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c 🚂 <details><summary>Show signature</summary> Signature: ``` untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}" RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM= trusted comment: review ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c 🚂 0RN8toZudX3WfXDZvsUbFkOd9P5Kd1le5Ef2zAGNlR9jHQMC0uLLAW10sHCvqSo5XvCP6+k/ZD/wjaINsvKADA== ``` </details>
stickies-v commented 2026-10-16 07:58:46 +00:00 (Migrated from github.com)
ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c
sedited (Migrated from github.com) approved these changes 2026-10-19 07:53:48 +00:00
sedited (Migrated from github.com) left a comment
ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36524
No description provided.