# HG changeset patch # User Mads Kiilerich # Date 2020-10-28 21:24:13 # Node ID 1f8eaa4c1dff7dc5927d0ef2a37b48bbf14a1088 # Parent 410934dd09f4c8e01a8efd916e1a5533bdc3bde8 lib: move locale.py to locales.py to avoid shadowing of standard module "Fix" spurious problem, seen for example as: $ python kallithea/lib/annotate.py Traceback (most recent call last): File ".../lib64/python3.8/site-packages/mercurial/encoding.py", line 107, in encoding = locale.getpreferredencoding().encode('ascii') or b'ascii' AttributeError: module 'locale' has no attribute 'getpreferredencoding' That happened when something in some other module tried to import stdlib locale ... but somehow would pick up the kallithea locale module and things would fail. Stay out of that kind of trouble by using a name that doesn't collide. diff --git a/kallithea/bin/kallithea_cli_config.py b/kallithea/bin/kallithea_cli_config.py --- a/kallithea/bin/kallithea_cli_config.py +++ b/kallithea/bin/kallithea_cli_config.py @@ -21,7 +21,7 @@ import click import mako.exceptions import kallithea.bin.kallithea_cli_base as cli_base -import kallithea.lib.locale +import kallithea.lib.locales from kallithea.lib import inifile @@ -66,7 +66,7 @@ def config_create(config_file, key_value 'git_hook_interpreter': sys.executable, 'user_home_path': os.path.expanduser('~'), 'kallithea_cli_path': cli_base.kallithea_cli_path, - 'ssh_locale': kallithea.lib.locale.get_current_locale(), + 'ssh_locale': kallithea.lib.locales.get_current_locale(), } ini_settings = defaultdict(dict) diff --git a/kallithea/config/app_cfg.py b/kallithea/config/app_cfg.py --- a/kallithea/config/app_cfg.py +++ b/kallithea/config/app_cfg.py @@ -30,7 +30,7 @@ from alembic.script.base import ScriptDi from sqlalchemy import create_engine from tg import FullStackApplicationConfigurator -import kallithea.lib.locale +import kallithea.lib.locales import kallithea.model.base import kallithea.model.meta from kallithea.lib import celerypylons @@ -99,7 +99,7 @@ else: def setup_configuration(app): config = app.config - if not kallithea.lib.locale.current_locale_is_valid(): + if not kallithea.lib.locales.current_locale_is_valid(): log.error("Terminating ...") sys.exit(1) diff --git a/kallithea/lib/locale.py b/kallithea/lib/locales.py rename from kallithea/lib/locale.py rename to kallithea/lib/locales.py