Commit 064e3933 authored by Petri Lehtinen's avatar Petri Lehtinen

Issue #3067: Enhance the documentation and docstring of locale.setlocale()

parents 8c481b62 395ca723
...@@ -22,19 +22,19 @@ The :mod:`locale` module defines the following exception and functions: ...@@ -22,19 +22,19 @@ The :mod:`locale` module defines the following exception and functions:
.. exception:: Error .. exception:: Error
Exception raised when :func:`setlocale` fails. Exception raised when the locale passed to :func:`setlocale` is not
recognized.
.. function:: setlocale(category, locale=None) .. function:: setlocale(category, locale=None)
If *locale* is specified, it may be a string, a tuple of the form ``(language If *locale* is given and not ``None``, :func:`setlocale` modifies the locale
code, encoding)``, or ``None``. If it is a tuple, it is converted to a string setting for the *category*. The available categories are listed in the data
using the locale aliasing engine. If *locale* is given and not ``None``, description below. *locale* may be a string, or an iterable of two strings
:func:`setlocale` modifies the locale setting for the *category*. The available (language code and encoding). If it's an iterable, it's converted to a locale
categories are listed in the data description below. The value is the name of a name using the locale aliasing engine. An empty string specifies the user's
locale. An empty string specifies the user's default settings. If the default settings. If the modification of the locale fails, the exception
modification of the locale fails, the exception :exc:`Error` is raised. If :exc:`Error` is raised. If successful, the new locale setting is returned.
successful, the new locale setting is returned.
If *locale* is omitted or ``None``, the current setting for *category* is If *locale* is omitted or ``None``, the current setting for *category* is
returned. returned.
......
...@@ -526,9 +526,10 @@ def getlocale(category=LC_CTYPE): ...@@ -526,9 +526,10 @@ def getlocale(category=LC_CTYPE):
def setlocale(category, locale=None): def setlocale(category, locale=None):
""" Set the locale for the given category. The locale can be """ 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. engine. Locale strings are passed directly to the C lib.
category may be given as one of the LC_* values. category may be given as one of the LC_* values.
......
...@@ -358,7 +358,8 @@ Library ...@@ -358,7 +358,8 @@ Library
are read correctly. are read correctly.
- Issue #3067: locale.setlocale() now raises TypeError if the second - Issue #3067: locale.setlocale() now raises TypeError if the second
argument is an invalid iterable. Initial patch by Jyrki Pulliainen. argument is an invalid iterable. Its documentation and docstring
were also updated. Initial patch by Jyrki Pulliainen.
- Issue #13140: Fix the daemon_threads attribute of ThreadingMixIn. - Issue #13140: Fix the daemon_threads attribute of ThreadingMixIn.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment