summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2011-11-05 08:18:50 (GMT)
committerPetri Lehtinen <petri@digip.org>2011-11-05 08:21:16 (GMT)
commit395ca7238015eb5aacadde2917c185cba5fea726 (patch)
tree5f6a1fe3e86554d18644fe479e20cd14ad6e7c8d
parent8c482ee95564f04df01fc856f313ff8c98846718 (diff)
downloadcpython-395ca7238015eb5aacadde2917c185cba5fea726.zip
cpython-395ca7238015eb5aacadde2917c185cba5fea726.tar.gz
cpython-395ca7238015eb5aacadde2917c185cba5fea726.tar.bz2
Issue #3067: Enhance the documentation and docstring of locale.setlocale()
-rw-r--r--Doc/library/locale.rst18
-rw-r--r--Lib/locale.py5
-rw-r--r--Misc/NEWS3
3 files changed, 14 insertions, 12 deletions
diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index dd6f954..3a49e98 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -22,19 +22,19 @@ The :mod:`locale` module defines the following exception and functions:
.. 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)
- 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.
diff --git a/Lib/locale.py b/Lib/locale.py
index 58cf0a7..d9dbce6 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -526,9 +526,10 @@ def getlocale(category=LC_CTYPE):
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 --git a/Misc/NEWS b/Misc/NEWS
index 22400c6..5ac8c98 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -74,7 +74,8 @@ Library
are read correctly.
- 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.