]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #3067: Enhance the documentation and docstring of locale.setlocale()
authorPetri Lehtinen <petri@digip.org>
Sat, 5 Nov 2011 08:18:50 +0000 (10:18 +0200)
committerPetri Lehtinen <petri@digip.org>
Sat, 5 Nov 2011 08:21:16 +0000 (10:21 +0200)
Doc/library/locale.rst
Lib/locale.py
Misc/NEWS

index dd6f9547f7ea7f4807f942a2798233f4b5d10805..3a49e98173a8592b0e95a836ac3527cc12b150bd 100644 (file)
@@ -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.
index 58cf0a75b37c42b9f7e22ba7756b96ba60a03ed9..d9dbce65a8ddd4aaeac4a6167615c0392326cf44 100644 (file)
@@ -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.
index 22400c68ede869a5d9804cbd57acc7c6fac95427..5ac8c98e7534380e74a7e0cb9917ef827567c361 100644 (file)
--- 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.