Bugs item #1703592, was opened at 2007-04-19 15:35
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1703592&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Matthias Klose (doko)
Assigned to: Martin v. Löwis (loewis)
Summary: have a way to ignore nonexisting locales in locale.setlocale

Initial Comment:
this came up on #ubuntu-devel; Debian and Ubuntu do not generate all libc 
locales by default, so it is likely that 

$ LC_ALL=en_US.UTF-8 python -c "import locale; locale.setlocale(locale.LC_ALL, 
'')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/locale.py", line 476, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

fails on a system (often experienced ssh'ing into a server system where your 
current locale doesn't exist). Examples for bug reports in various applications 
are:

  https://launchpad.net/bugs/91583 (apt-listchanges)
  https://launchpad.net/bugs/88638 (pitivi)
  https://launchpad.net/bugs/81556 (exaile)
  https://launchpad.net/bugs/90525 (hwdb-client)

In C, the result of the setlocale(3) call can be, and usually is ignored, if 
the locale cannot be set.

It is argued that the Python interface for locale.setlocale() should not raise 
an exception by default, if the locale is missing on the system.

That would be an behaviour change of locale.setlocale(), so the original 
behavour should be kept as an option (introducing an optional third parameter 
to raise the exception when the locale doesn't exist). Is this an appropriate 
change, or could another change be suggested?


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2007-04-19 19:50

Message:
Logged In: YES 
user_id=21627
Originator: NO

Not raising an exception if an operation failed violates the Zen of Python
(errors should never pass silently, unless explicitly silenced). So
explicit silencing is necessary, but if so, it's easy enough to explicitly
catch the exception:

try:
  locale.setlocale(..)
except locale.Error:
  pass

If the intention is that all software on Debian works successfully even if
the locale is configured incorrectly, then an automated build system should
perform all builds in a non-existing locale, and see if anything fails.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1703592&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to