Changeset - 1f8eaa4c1dff
[Not reviewed]
default
1 2 1
Mads Kiilerich - 5 years ago 2020-10-28 21:24:13
mads@kiilerich.com
Grafted from: deb7c57f11be
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 <module>
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.
3 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_config.py
Show inline comments
 
@@ -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)
 

	
kallithea/config/app_cfg.py
Show inline comments
 
@@ -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)
 

	
kallithea/lib/locales.py
Show inline comments
 
file renamed from kallithea/lib/locale.py to kallithea/lib/locales.py
0 comments (0 inline, 0 general)