From 62073ab70831620d30c8dbd61aaa32dd20f35d5e Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Thu, 6 Mar 2025 16:23:34 +1100 Subject: [PATCH] Use locale.getlocale() instead of deprecated locale.getdefaultlocale() --- cli/onionshare_cli/settings.py | 2 +- cli/tests/conftest.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/onionshare_cli/settings.py b/cli/onionshare_cli/settings.py index 4cd56ee9..7ae32fe0 100644 --- a/cli/onionshare_cli/settings.py +++ b/cli/onionshare_cli/settings.py @@ -140,7 +140,7 @@ class Settings(object): # Choose the default locale based on the OS preference, and fall-back to English if self._settings["locale"] is None: - language_code, encoding = locale.getdefaultlocale() + language_code, encoding = locale.getlocale() # Default to English if not language_code: diff --git a/cli/tests/conftest.py b/cli/tests/conftest.py index f4d51f9d..bf5071ca 100644 --- a/cli/tests/conftest.py +++ b/cli/tests/conftest.py @@ -1,6 +1,6 @@ -import sys import os import shutil +import sys import tempfile import pytest @@ -116,22 +116,22 @@ def default_zw(): @pytest.fixture def locale_en(monkeypatch): - monkeypatch.setattr("locale.getdefaultlocale", lambda: ("en_US", "UTF-8")) + monkeypatch.setattr("locale.getlocale", lambda: ("en_US", "UTF-8")) @pytest.fixture def locale_fr(monkeypatch): - monkeypatch.setattr("locale.getdefaultlocale", lambda: ("fr_FR", "UTF-8")) + monkeypatch.setattr("locale.getlocale", lambda: ("fr_FR", "UTF-8")) @pytest.fixture def locale_invalid(monkeypatch): - monkeypatch.setattr("locale.getdefaultlocale", lambda: ("xx_XX", "UTF-8")) + monkeypatch.setattr("locale.getlocale", lambda: ("xx_XX", "UTF-8")) @pytest.fixture def locale_ru(monkeypatch): - monkeypatch.setattr("locale.getdefaultlocale", lambda: ("ru_RU", "UTF-8")) + monkeypatch.setattr("locale.getlocale", lambda: ("ru_RU", "UTF-8")) @pytest.fixture