Merged revisions 68582,68718,68720-68721,68724-68727,68859,68973,69288-69289,69293,69295,69297-69301,69409,69414,69570,69573,69576,69728-69730,69769,69776,69803-69805,69840,69896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68582 | georg.brandl | 2009-01-13 23:14:01 +0100 (Di, 13 Jan 2009) | 2 lines

  Use assertRaises.
........
  r68718 | georg.brandl | 2009-01-18 11:42:35 +0100 (So, 18 Jan 2009) | 1 line

  #4976: union() and intersection() take multiple args, but talk about "the other".
........
  r68720 | georg.brandl | 2009-01-18 11:45:22 +0100 (So, 18 Jan 2009) | 1 line

  #4974: fix redundant mention of lists and tuples.
........
  r68721 | georg.brandl | 2009-01-18 11:48:16 +0100 (So, 18 Jan 2009) | 1 line

  #4914: trunc is in math.
........
  r68724 | georg.brandl | 2009-01-18 14:24:10 +0100 (So, 18 Jan 2009) | 1 line

  #4979: correct result range for some random functions.
........
  r68725 | georg.brandl | 2009-01-18 14:47:26 +0100 (So, 18 Jan 2009) | 1 line

  #4857: fix augmented assignment target spec.
........
  r68726 | georg.brandl | 2009-01-18 15:41:52 +0100 (So, 18 Jan 2009) | 1 line

  #4923: clarify what was added.
........
  r68727 | georg.brandl | 2009-01-18 19:25:30 +0100 (So, 18 Jan 2009) | 1 line

  #4986: augassigns are not expressions.
........
  r68859 | georg.brandl | 2009-01-22 19:29:28 +0100 (Do, 22 Jan 2009) | 2 lines

  Clarify wording.
........
  r68973 | georg.brandl | 2009-01-26 22:29:38 +0100 (Mo, 26 Jan 2009) | 2 lines

  Copy over docs on advanced role features from Sphinx docs.
........
  r69288 | georg.brandl | 2009-02-05 11:30:57 +0100 (Do, 05 Feb 2009) | 1 line

  #5153: fix typo in example.
........
  r69289 | georg.brandl | 2009-02-05 11:37:07 +0100 (Do, 05 Feb 2009) | 1 line

  #5144: document that PySys_SetArgv prepends the script directory (or the empty string) to sys.path.
........
  r69293 | georg.brandl | 2009-02-05 11:59:28 +0100 (Do, 05 Feb 2009) | 1 line

  #5059: fix example.
........
  r69295 | georg.brandl | 2009-02-05 12:23:47 +0100 (Do, 05 Feb 2009) | 1 line

  PyErr_PrintEx is also in 2.x...
........
  r69297 | georg.brandl | 2009-02-05 12:32:18 +0100 (Do, 05 Feb 2009) | 1 line

  #5015: document PythonHome API functions.
........
  r69298 | georg.brandl | 2009-02-05 12:33:21 +0100 (Do, 05 Feb 2009) | 1 line

  #4827: fix callback example.
........
  r69299 | georg.brandl | 2009-02-05 12:35:28 +0100 (Do, 05 Feb 2009) | 1 line

  #4820: use correct module for ctypes.util.
........
  r69300 | georg.brandl | 2009-02-05 12:38:23 +0100 (Do, 05 Feb 2009) | 1 line

  #4563: disable alpha and roman lists, fixes wrong formatting of contributor list.
........
  r69301 | georg.brandl | 2009-02-05 12:40:35 +0100 (Do, 05 Feb 2009) | 1 line

  #5031: fix Thread.daemon property docs.
........
  r69409 | georg.brandl | 2009-02-07 13:21:17 +0100 (Sa, 07 Feb 2009) | 1 line

  #5174: fix wrong file closing in example.
........
  r69414 | georg.brandl | 2009-02-07 19:49:54 +0100 (Sa, 07 Feb 2009) | 1 line

  make "super only for new-style classes" a note.
........
  r69570 | georg.brandl | 2009-02-13 11:40:14 +0100 (Fr, 13 Feb 2009) | 1 line

  #4894: document "newurl" parameter to redirect_request().
........
  r69573 | georg.brandl | 2009-02-13 11:44:17 +0100 (Fr, 13 Feb 2009) | 1 line

  #3734: document complex coercing behavior better.
........
  r69576 | georg.brandl | 2009-02-13 11:56:50 +0100 (Fr, 13 Feb 2009) | 1 line

  #1661108: note that urlsafe encoded string can contain "=".
........
  r69728 | georg.brandl | 2009-02-18 01:22:55 +0100 (Mi, 18 Feb 2009) | 2 lines

  #5297: fix example.
........
  r69729 | georg.brandl | 2009-02-18 01:25:13 +0100 (Mi, 18 Feb 2009) | 2 lines

  #5296: sequence -> iterable.
........
  r69730 | georg.brandl | 2009-02-18 01:31:36 +0100 (Mi, 18 Feb 2009) | 2 lines

  #5268: mention VMSError.
........
  r69769 | georg.brandl | 2009-02-19 09:30:06 +0100 (Do, 19 Feb 2009) | 1 line

  #5310, #3558: fix operator precedence table.
........
  r69776 | georg.brandl | 2009-02-19 17:34:51 +0100 (Do, 19 Feb 2009) | 2 lines

  #5317: update IronPython URL.
........
  r69803 | georg.brandl | 2009-02-20 08:48:21 +0100 (Fr, 20 Feb 2009) | 1 line

  #5327: fix a broken link by joining it.
........
  r69804 | georg.brandl | 2009-02-20 09:22:21 +0100 (Fr, 20 Feb 2009) | 1 line

  At least separate imports from other statements.
........
  r69805 | georg.brandl | 2009-02-20 09:45:47 +0100 (Fr, 20 Feb 2009) | 2 lines

  Fix punctuation.
........
  r69840 | georg.brandl | 2009-02-21 20:09:40 +0100 (Sa, 21 Feb 2009) | 1 line

  #5338, #5339: two types in the API manual.
........
  r69896 | georg.brandl | 2009-02-23 11:24:23 +0100 (Mo, 23 Feb 2009) | 1 line

  #5348: format() converts all kinds of values.
........
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst
index 68a941f..084660d 100644
--- a/Doc/library/base64.rst
+++ b/Doc/library/base64.rst
@@ -63,7 +63,8 @@
 .. function:: urlsafe_b64encode(s)
 
    Encode string *s* using a URL-safe alphabet, which substitutes ``-`` instead of
-   ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet.
+   ``+`` and ``_`` instead of ``/`` in the standard Base64 alphabet.  The result
+   can still contain ``=``.
 
 
 .. function:: urlsafe_b64decode(s)
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst
index 0248284..3879e0d 100644
--- a/Doc/library/cgi.rst
+++ b/Doc/library/cgi.rst
@@ -67,16 +67,18 @@
 module defines all sorts of names for its own use or for backward compatibility
 that you don't want in your namespace.
 
-When you write a new script, consider adding the line::
+When you write a new script, consider adding these lines::
 
-   import cgitb; cgitb.enable()
+   import cgitb
+   cgitb.enable()
 
 This activates a special exception handler that will display detailed reports in
 the Web browser if any errors occur.  If you'd rather not show the guts of your
 program to users of your script, you can have the reports saved to files
-instead, with a line like this::
+instead, with code like this::
 
-   import cgitb; cgitb.enable(display=0, logdir="/tmp")
+   import cgitb
+   cgitb.enable(display=0, logdir="/tmp")
 
 It's very helpful to use this feature during script development. The reports
 produced by :mod:`cgitb` provide information that can save you a lot of time in
@@ -470,9 +472,10 @@
 
 Fortunately, once you have managed to get your script to execute *some* code,
 you can easily send tracebacks to the Web browser using the :mod:`cgitb` module.
-If you haven't done so already, just add the line::
+If you haven't done so already, just add the lines::
 
-   import cgitb; cgitb.enable()
+   import cgitb
+   cgitb.enable()
 
 to the top of your script.  Then try running it again; when a problem occurs,
 you should see a detailed report that will likely make apparent the cause of the
diff --git a/Doc/library/cgitb.rst b/Doc/library/cgitb.rst
index 327cd17..052b821 100644
--- a/Doc/library/cgitb.rst
+++ b/Doc/library/cgitb.rst
@@ -26,9 +26,10 @@
 functions, to help you debug the problem.  Optionally, you can save this
 information to a file instead of sending it to the browser.
 
-To enable this feature, simply add one line to the top of your CGI script::
+To enable this feature, simply add this to the top of your CGI script::
 
-   import cgitb; cgitb.enable()
+   import cgitb
+   cgitb.enable()
 
 The options to the :func:`enable` function control whether the report is
 displayed in the browser and whether the report is logged to a file for later
diff --git a/Doc/library/cookielib.rst b/Doc/library/cookielib.rst
index f55d6c2..12a12a0 100644
--- a/Doc/library/cookielib.rst
+++ b/Doc/library/cookielib.rst
@@ -769,7 +769,7 @@
    import urllib2
    from cookielib import CookieJar, DefaultCookiePolicy
    policy = DefaultCookiePolicy(
-       rfc2965=True, strict_ns_domain=Policy.DomainStrict,
+       rfc2965=True, strict_ns_domain=DefaultCookiePolicy.DomainStrict,
        blocked_domains=["ads.net", ".ads.net"])
    cj = CookieJar(policy)
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 9ff3de0..c7c3b00 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1274,6 +1274,7 @@
 
 
 .. data:: find_library(name)
+   :module: ctypes.util
    :noindex:
 
    Try to find a library and return a pathname.  *name* is the library name without
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 637326d..0996276 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -1497,11 +1497,10 @@
 microseconds should not be used, as :class:`date` objects have no such
 values.  If they're used anyway, ``0`` is substituted for them.
 
-:class:`time` and :class:`datetime` objects support a ``%f`` format code
-which expands to the number of microseconds in the object, zero-padded on
-the left to six places.
-
 .. versionadded:: 2.6
+   :class:`time` and :class:`datetime` objects support a ``%f`` format code
+   which expands to the number of microseconds in the object, zero-padded on
+   the left to six places.
 
 For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
 strings.
@@ -1621,7 +1620,9 @@
 (1)
    When used with the :func:`strptime` function, the ``%f`` directive
    accepts from one to six digits and zero pads on the right.  ``%f`` is
-   an extension to the set of format characters in the C standard.
+   an extension to the set of format characters in the C standard (but
+   implemented separately in datetime objects, and therefore always
+   available).
 
 (2)
    When used with the :func:`strptime` function, the ``%p`` directive only affects
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 01b54b3..9673dab 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -398,6 +398,11 @@
    more precise exception such as :exc:`IndexError`.
 
 
+.. exception:: VMSError
+
+   Only available on VMS.  Raised when a VMS-specific error occurs.
+
+
 .. exception:: WindowsError
 
    Raised when a Windows-specific error occurs or when the error number does not
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 63a2e3e..7a31323 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -425,6 +425,26 @@
 
    The float type is described in :ref:`typesnumeric`.
 
+
+.. function:: format(value[, format_spec])
+
+   .. index::
+      pair: str; format
+      single: __format__
+
+   Convert a *value* to a "formatted" representation, as controlled by
+   *format_spec*.  The interpretation of *format_spec* will depend on the type
+   of the *value* argument, however there is a standard formatting syntax that
+   is used by most built-in types: :ref:`formatspec`.
+
+   .. note::
+
+      ``format(value, format_spec)`` merely calls
+      ``value.__format__(format_spec)``.
+
+   .. versionadded:: 2.6
+
+
 .. function:: frozenset([iterable])
    :noindex:
 
@@ -1178,8 +1198,10 @@
    If the second argument is omitted the super
    object returned is unbound.  If the second argument is an object,
    ``isinstance(obj, type)`` must be true.  If the second argument is a type,
-   ``issubclass(type2, type)`` must be true. :func:`super` only works for
-   :term:`new-style class`\es.
+   ``issubclass(type2, type)`` must be true.
+
+   .. note::
+      :func:`super` only works for :term:`new-style class`\es.
 
    There are two typical use cases for "super".  In a class hierarchy with
    single inheritance, "super" can be used to refer to parent classes without
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst
index 6af4074..4ef2ba7 100644
--- a/Doc/library/optparse.rst
+++ b/Doc/library/optparse.rst
@@ -1511,7 +1511,7 @@
 records that the option was seen::
 
    def record_foo_seen(option, opt_str, value, parser):
-       parser.saw_foo = True
+       parser.values.saw_foo = True
 
    parser.add_option("--foo", action="callback", callback=record_foo_seen)
 
@@ -1651,7 +1651,7 @@
             value.append(arg)
 
         del parser.rargs[:len(value)]
-        setattr(parser.values, option.dest, value))
+        setattr(parser.values, option.dest, value)
 
    [...]
    parser.add_option("-c", "--callback", dest="vararg_attr",
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 63c4bc7..9e55665 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -188,13 +188,13 @@
 
 .. function:: uniform(a, b)
 
-   Return a random floating point number *N* such that ``a <= N < b`` for
-   ``a <= b`` and ``b <= N < a`` for ``b < a``.
+   Return a random floating point number *N* such that ``a <= N <= b`` for
+   ``a <= b`` and ``b <= N <= a`` for ``b < a``.
 
 
 .. function:: triangular(low, high, mode)
 
-   Return a random floating point number *N* such that ``low <= N < high`` and
+   Return a random floating point number *N* such that ``low <= N <= high`` and
    with the specified *mode* between those bounds.  The *low* and *high* bounds
    default to zero and one.  The *mode* argument defaults to the midpoint
    between the bounds, giving a symmetric distribution.
@@ -204,8 +204,8 @@
 
 .. function:: betavariate(alpha, beta)
 
-   Beta distribution.  Conditions on the parameters are ``alpha > 0`` and ``beta >
-   0``. Returned values range between 0 and 1.
+   Beta distribution.  Conditions on the parameters are ``alpha > 0`` and
+   ``beta > 0``. Returned values range between 0 and 1.
 
 
 .. function:: expovariate(lambd)
@@ -219,14 +219,15 @@
 
 .. function:: gammavariate(alpha, beta)
 
-   Gamma distribution.  (*Not* the gamma function!)  Conditions on the parameters
-   are ``alpha > 0`` and ``beta > 0``.
+   Gamma distribution.  (*Not* the gamma function!)  Conditions on the
+   parameters are ``alpha > 0`` and ``beta > 0``.
 
 
 .. function:: gauss(mu, sigma)
 
-   Gaussian distribution.  *mu* is the mean, and *sigma* is the standard deviation.
-   This is slightly faster than the :func:`normalvariate` function defined below.
+   Gaussian distribution.  *mu* is the mean, and *sigma* is the standard
+   deviation.  This is slightly faster than the :func:`normalvariate` function
+   defined below.
 
 
 .. function:: lognormvariate(mu, sigma)
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index 6ae9038..a4f181b 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -517,7 +517,7 @@
        # Exit the server thread when the main thread terminates
        server_thread.setDaemon(True)
        server_thread.start()
-       print "Server loop running in thread:", t.getName()
+       print "Server loop running in thread:", server_thread.getName()
 
        client(ip, port, "Hello World 1")
        client(ip, port, "Hello World 2")
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 1ee7ea2..0434ff2 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -375,7 +375,7 @@
 +--------------------+------------------------------------+--------+
 | Operation          | Result                             | Notes  |
 +====================+====================================+========+
-| ``trunc(x)``       | *x* truncated to Integral          |        |
+| ``math.trunc(x)``  | *x* truncated to Integral          |        |
 +--------------------+------------------------------------+--------+
 | ``round(x[, n])``  | *x* rounded to n digits,           |        |
 |                    | rounding half to even. If n is     |        |
@@ -601,9 +601,9 @@
 
 There are six sequence types: strings, Unicode strings, lists, tuples, buffers,
 and xrange objects.
-(For other containers see the built in :class:`dict`, :class:`list`,
-:class:`set`, and :class:`tuple` classes, and the :mod:`collections`
-module.)
+
+For other containers see the built in :class:`dict` and :class:`set` classes,
+and the :mod:`collections` module.
 
 
 .. index::
@@ -1648,7 +1648,7 @@
    .. method:: union(other, ...)
                set | other | ...
 
-      Return a new set with elements from both sets.
+      Return a new set with elements from the set and all others.
 
       .. versionchanged:: 2.6
          Accepts multiple input iterables.
@@ -1656,7 +1656,7 @@
    .. method:: intersection(other, ...)
                set & other & ...
 
-      Return a new set with elements common to both sets.
+      Return a new set with elements common to the set and all others.
 
       .. versionchanged:: 2.6
          Accepts multiple input iterables.
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 85860e5..e6616db 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -210,7 +210,7 @@
 A thread can be flagged as a "daemon thread".  The significance of this flag is
 that the entire Python program exits when only daemon threads are left.  The
 initial value is inherited from the creating thread.  The flag can be set
-through the :attr:`daemon` attribute.
+through the :attr:`daemon` property.
 
 There is a "main thread" object; this corresponds to the initial thread of
 control in the Python program.  It is not a daemon thread.
@@ -332,10 +332,11 @@
 
 .. attribute:: Thread.daemon
 
-   The thread's daemon flag. This must be set before :meth:`start` is called,
-   otherwise :exc:`RuntimeError` is raised.
-
-   The initial value is inherited from the creating thread.
+   A boolean value indicating whether this thread is a daemon thread (True) or
+   not (False).  This must be set before :meth:`start` is called, otherwise
+   :exc:`RuntimeError` is raised.  Its initial value is inherited from the
+   creating thread; the main thread is not a daemon thread and therefore all
+   threads created in the main thread default to :attr:`daemon` = ``False``.
 
    The entire Python program exits when no alive non-daemon threads are left.
 
diff --git a/Doc/library/urllib2.rst b/Doc/library/urllib2.rst
index 986e545..e6f8061 100644
--- a/Doc/library/urllib2.rst
+++ b/Doc/library/urllib2.rst
@@ -602,14 +602,15 @@
    precise meanings of the various redirection codes.
 
 
-.. method:: HTTPRedirectHandler.redirect_request(req, fp, code, msg, hdrs)
+.. method:: HTTPRedirectHandler.redirect_request(req, fp, code, msg, hdrs, newurl)
 
    Return a :class:`Request` or ``None`` in response to a redirect. This is called
    by the default implementations of the :meth:`http_error_30\*` methods when a
    redirection is received from the server.  If a redirection should take place,
    return a new :class:`Request` to allow :meth:`http_error_30\*` to perform the
-   redirect.  Otherwise, raise :exc:`HTTPError` if no other handler should try to
-   handle this URL, or return ``None`` if you can't but another handler might.
+   redirect to *newurl*.  Otherwise, raise :exc:`HTTPError` if no other handler
+   should try to handle this URL, or return ``None`` if you can't but another
+   handler might.
 
    .. note::
 
@@ -622,8 +623,8 @@
 
 .. method:: HTTPRedirectHandler.http_error_301(req, fp, code, msg, hdrs)
 
-   Redirect to the ``Location:`` URL.  This method is called by the parent
-   :class:`OpenerDirector` when getting an HTTP 'moved permanently' response.
+   Redirect to the ``Location:`` or ``URI:`` URL.  This method is called by the
+   parent :class:`OpenerDirector` when getting an HTTP 'moved permanently' response.
 
 
 .. method:: HTTPRedirectHandler.http_error_302(req, fp, code, msg, hdrs)
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index 9aa1ea3..38545c2 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -529,5 +529,5 @@
 .. [#] The encoding string included in XML output should conform to the
    appropriate standards. For example, "UTF-8" is valid, but "UTF8" is
    not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl
-   and http://www.iana.org/assignments/character-sets .
+   and http://www.iana.org/assignments/character-sets.
 
diff --git a/Doc/library/xmlrpclib.rst b/Doc/library/xmlrpclib.rst
index 039a8a8..4035f8e 100644
--- a/Doc/library/xmlrpclib.rst
+++ b/Doc/library/xmlrpclib.rst
@@ -318,9 +318,8 @@
    import xmlrpclib
 
    def python_logo():
-        handle = open("python_logo.jpg")
-        return xmlrpclib.Binary(handle.read())
-        handle.close()
+        with open("python_logo.jpg") as handle:
+            return xmlrpclib.Binary(handle.read())
 
    server = SimpleXMLRPCServer(("localhost", 8000))
    print "Listening on port 8000..."
@@ -333,9 +332,8 @@
    import xmlrpclib
 
    proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
-   handle = open("fetched_python_logo.jpg", "w")
-   handle.write(proxy.python_logo().data)
-   handle.close()
+   with open("fetched_python_logo.jpg", "w") as handle:
+       handle.write(proxy.python_logo().data)
 
 .. _fault-objects: