(original) (raw)

changeset: 73372:34c9465f5023 branch: 2.7 user: Petri Lehtinen petri@digip.org date: Sat Nov 05 10🔞50 2011 +0200 files: Doc/library/locale.rst Lib/locale.py Misc/NEWS description: Issue #3067: Enhance the documentation and docstring of locale.setlocale() diff -r 0b754ee12dbd -r 34c9465f5023 Doc/library/locale.rst --- a/Doc/library/locale.rst Sat Nov 05 09:50:37 2011 +0200 +++ b/Doc/library/locale.rst Sat Nov 05 10🔞50 2011 +0200 @@ -23,19 +23,19 @@ .. exception:: Error - Exception raised when :func:`setlocale` fails. + Exception raised when the locale passed to :func:`setlocale` is not + recognized. .. function:: setlocale(category[, locale]) - If *locale* is specified, it may be a string, a tuple of the form ``(language - code, encoding)``, or ``None``. If it is a tuple, it is converted to a string - using the locale aliasing engine. If *locale* is given and not ``None``, - :func:`setlocale` modifies the locale setting for the *category*. The available - categories are listed in the data description below. The value is the name of a - locale. An empty string specifies the user's default settings. If the - modification of the locale fails, the exception :exc:`Error` is raised. If - successful, the new locale setting is returned. + If *locale* is given and not ``None``, :func:`setlocale` modifies the locale + setting for the *category*. The available categories are listed in the data + description below. *locale* may be a string, or an iterable of two strings + (language code and encoding). If it's an iterable, it's converted to a locale + name using the locale aliasing engine. An empty string specifies the user's + default settings. If the modification of the locale fails, the exception + :exc:`Error` is raised. If successful, the new locale setting is returned. If *locale* is omitted or ``None``, the current setting for *category* is returned. @@ -51,7 +51,7 @@ changed thereafter, using multithreading should not cause problems. .. versionchanged:: 2.0 - Added support for tuple values of the *locale* parameter. + Added support for iterable values of the *locale* parameter. .. function:: localeconv() diff -r 0b754ee12dbd -r 34c9465f5023 Lib/locale.py --- a/Lib/locale.py Sat Nov 05 09:50:37 2011 +0200 +++ b/Lib/locale.py Sat Nov 05 10🔞50 2011 +0200 @@ -524,9 +524,10 @@ def setlocale(category, locale=None): """ Set the locale for the given category. The locale can be - a string, a locale tuple (language code, encoding), or None. + a string, an iterable of two strings (language code and encoding), + or None. - Locale tuples are converted to strings the locale aliasing + Iterables are converted to strings using the locale aliasing engine. Locale strings are passed directly to the C lib. category may be given as one of the LC_* values. diff -r 0b754ee12dbd -r 34c9465f5023 Misc/NEWS --- a/Misc/NEWS Sat Nov 05 09:50:37 2011 +0200 +++ b/Misc/NEWS Sat Nov 05 10🔞50 2011 +0200 @@ -74,6 +74,9 @@ Library ------- +- Issue #3067: Enhance the documentation and docstring of + locale.setlocale(). + - Issue #13254: Fix Maildir initialization so that maildir contents are read correctly. /petri@digip.org