Skip to content

Commit

Permalink
Don't exit if setlocale() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Nov 10, 2021
1 parent 6bc4450 commit 8d47b65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion reprounzip-qt/reprounzip_qt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from reprounzip.common import setup_logging
from reprounzip_qt import __version__
from reprounzip_qt.usage import record_usage, submit_usage_report
from reprozip.utils import stderr


logger = logging.getLogger('reprounzip_qt')
Expand All @@ -21,7 +22,10 @@ def main():
"""Entry point when called on the command-line.
"""
# Locale
locale.setlocale(locale.LC_ALL, '')
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error as e:
stderr.write("Couldn't set locale: %s\n" % e)

parser = argparse.ArgumentParser(
description="Graphical user interface for reprounzip",
Expand Down
6 changes: 5 additions & 1 deletion reprounzip/reprounzip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
submit_usage_report, record_usage
from reprounzip import signals
from reprounzip.unpackers.common import UsageError
from reprozip.utils import stderr


__version__ = '1.1'
Expand Down Expand Up @@ -79,7 +80,10 @@ def main():
"""Entry point when called on the command-line.
"""
# Locale
locale.setlocale(locale.LC_ALL, '')
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error as e:
stderr.write("Couldn't set locale: %s\n" % e)

# Parses command-line

Expand Down
5 changes: 4 additions & 1 deletion reprozip/reprozip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ def main():
"""Entry point when called on the command-line.
"""
# Locale
locale.setlocale(locale.LC_ALL, '')
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error as e:
stderr.write("Couldn't set locale: %s\n" % e)

# http://bugs.python.org/issue13676
# This prevents reprozip from reading argv and envp arrays from trace
Expand Down

0 comments on commit 8d47b65

Please sign in to comment.