]> granicus.if.org Git - python/commitdiff
Merged revisions 68633,68648,68667,68706,68718,68720-68721,68724-68727,68739 via...
authorBenjamin Peterson <benjamin@python.org>
Sun, 18 Jan 2009 22:27:04 +0000 (22:27 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 18 Jan 2009 22:27:04 +0000 (22:27 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68633 | thomas.heller | 2009-01-16 12:53:44 -0600 (Fri, 16 Jan 2009) | 3 lines

  Change an example in the docs to avoid a mistake when the code is copy
  pasted and changed afterwards.
........
  r68648 | benjamin.peterson | 2009-01-16 22:28:57 -0600 (Fri, 16 Jan 2009) | 1 line

  use enumerate
........
  r68667 | amaury.forgeotdarc | 2009-01-17 14:18:59 -0600 (Sat, 17 Jan 2009) | 3 lines

  #4077: No need to append \n when calling Py_FatalError
  + fix a declaration to make it match the one in pythonrun.h
........
  r68706 | benjamin.peterson | 2009-01-17 19:28:46 -0600 (Sat, 17 Jan 2009) | 1 line

  fix grammar
........
  r68718 | georg.brandl | 2009-01-18 04:42:35 -0600 (Sun, 18 Jan 2009) | 1 line

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

  #4974: fix redundant mention of lists and tuples.
........
  r68721 | georg.brandl | 2009-01-18 04:48:16 -0600 (Sun, 18 Jan 2009) | 1 line

  #4914: trunc is in math.
........
  r68724 | georg.brandl | 2009-01-18 07:24:10 -0600 (Sun, 18 Jan 2009) | 1 line

  #4979: correct result range for some random functions.
........
  r68725 | georg.brandl | 2009-01-18 07:47:26 -0600 (Sun, 18 Jan 2009) | 1 line

  #4857: fix augmented assignment target spec.
........
  r68726 | georg.brandl | 2009-01-18 08:41:52 -0600 (Sun, 18 Jan 2009) | 1 line

  #4923: clarify what was added.
........
  r68727 | georg.brandl | 2009-01-18 12:25:30 -0600 (Sun, 18 Jan 2009) | 1 line

  #4986: augassigns are not expressions.
........
  r68739 | benjamin.peterson | 2009-01-18 15:11:38 -0600 (Sun, 18 Jan 2009) | 1 line

  fix test that wasn't working as expected #4990
........

13 files changed:
Doc/library/ctypes.rst
Doc/library/datetime.rst
Doc/library/random.rst
Doc/library/stdtypes.rst
Doc/reference/datamodel.rst
Doc/reference/simple_stmts.rst
Doc/tools/rstlint.py
Lib/inspect.py
Lib/test/test_codeccallbacks.py
Modules/_ctypes/libffi_msvc/ffi.c
Objects/exceptions.c
Python/ast.c
Python/compile.c

index f2ff1b693bcd064887a80ff1a13e929ba9bba81f..47f9819b4fcffca8dabb0ad66ab2456f58fa719c 100644 (file)
@@ -2406,10 +2406,10 @@ other data types containing pointer type fields.
                          ("hreftype", HREFTYPE)]
 
          class TYPEDESC(Structure):
+             _anonymous_ = ("u",)
              _fields_ = [("u", _U),
                          ("vt", VARTYPE)]
 
-             _anonymous_ = ("u",)
 
       The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
       specifies which one of the union fields is valid.  Since the ``u`` field
index c37ceb921b67f4cf69740d9e3cb9ffe2bf2e6bbc..e25d042ff9dcdd25aab60f58923f7f265c66a1b5 100644 (file)
@@ -1494,10 +1494,6 @@ For :class:`date` objects, the format codes for hours, minutes, seconds, and
 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.
-
 For a naive object, the ``%z`` and ``%Z`` format codes are replaced by empty
 strings.
 
@@ -1616,7 +1612,9 @@ Notes:
 (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
index 82d2555ceef368f6b25c16dab2e8e656ef3945ab..5dcf764bf0eaf7c172ba90ff905462be6148fcdf 100644 (file)
@@ -149,13 +149,13 @@ be found in any statistics text.
 
 .. 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.
@@ -163,8 +163,8 @@ be found in any statistics text.
 
 .. 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)
@@ -178,14 +178,15 @@ be found in any statistics text.
 
 .. 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)
index f67459ba0679adba0cbbcee889ead28fc3fd1de7..f2bc7af2946b26913c624ca70d2684fb1e599825 100644 (file)
@@ -343,19 +343,19 @@ Notes:
 All :class:`numbers.Real` types (:class:`int` and
 :class:`float`) also include the following operations:
 
-+--------------------+--------------------------------+--------+
-| Operation          | Result                         | Notes  |
-+====================+================================+========+
-| ``trunc(x)``       | *x* truncated to Integral      |        |
-+--------------------+--------------------------------+--------+
-| ``round(x[, n])``  | *x* rounded to n digits,       |        |
-|                    | rounding half to even. If n is |        |
-|                    | omitted, it defaults to 0.     |        |
-+--------------------+--------------------------------+--------+
-| ``math.floor(x)``  | the greatest Integral <= *x*   |        |
-+--------------------+--------------------------------+--------+
-| ``math.ceil(x)``   | the least Integral >= *x*      |        |
-+--------------------+--------------------------------+--------+
++--------------------+------------------------------------+--------+
+| Operation          | Result                             | Notes  |
++====================+====================================+========+
+| ``math.trunc(x)``  | *x* truncated to Integral          |        |
++--------------------+------------------------------------+--------+
+| ``round(x[, n])``  | *x* rounded to n digits,           |        |
+|                    | rounding half to even. If n is     |        |
+|                    | omitted, it defaults to 0.         |        |
++--------------------+------------------------------------+--------+
+| ``math.floor(x)``  | the greatest integral float <= *x* |        |
++--------------------+------------------------------------+--------+
+| ``math.ceil(x)``   | the least integral float >= *x*    |        |
++--------------------+------------------------------------+--------+
 
 For additional numeric operations see the :mod:`math` and :mod:`cmath`
 modules.
@@ -595,10 +595,10 @@ Sequence Types --- :class:`str`, :class:`bytes`, :class:`bytearray`, :class:`lis
 ==================================================================================================================
 
 There are six sequence types: strings, byte sequences (:class:`bytes` objects),
-byte arrays (:class:`bytearray` objects), lists, tuples, and range objects.
+byte arrays (:class:`bytearray` objects), lists, tuples, and range objects.  For
+other containers see the built in :class:`dict` and :class:`set` classes, and
+the :mod:`collections` module.
 
-For other containers see the built-in :class:`dict`, :class:`list`,
-:class:`set`, and :class:`tuple` classes, and the :mod:`collections` module.
 
 .. index::
    object: sequence
@@ -1623,12 +1623,12 @@ The constructors for both classes work the same:
    .. 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.
 
    .. 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.
 
    .. method:: difference(other, ...)
                set - other - ...
index 57fd63bdbc2b8911155b0c2e798e796627f89334..502305ddf8c990a684c3e39dc034a04c2054f7ff 100644 (file)
@@ -317,7 +317,7 @@ Sequences
       slicing notations can be used as the target of assignment and :keyword:`del`
       (delete) statements.
 
-      There is currently a single intrinsic mutable sequence type:
+      There are currently two intrinsic mutable sequence types:
 
       Lists
          .. index:: object: list
@@ -1777,13 +1777,13 @@ left undefined.
             object.__ixor__(self, other)
             object.__ior__(self, other)
 
-   These methods are called to implement the augmented arithmetic operations
+   These methods are called to implement the augmented arithmetic assignments
    (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``, ``**=``, ``<<=``, ``>>=``,
    ``&=``, ``^=``, ``|=``).  These methods should attempt to do the operation
    in-place (modifying *self*) and return the result (which could be, but does
    not have to be, *self*).  If a specific method is not defined, the augmented
-   operation falls back to the normal methods.  For instance, to evaluate the
-   expression ``x += y``, where *x* is an instance of a class that has an
+   assignment falls back to the normal methods.  For instance, to execute the
+   statement ``x += y``, where *x* is an instance of a class that has an
    :meth:`__iadd__` method, ``x.__iadd__(y)`` is called.  If *x* is an instance
    of a class that does not define a :meth:`__iadd__` method, ``x.__add__(y)``
    and ``y.__radd__(x)`` are considered, as with the evaluation of ``x + y``.
index 5793c09640973c6d2a9a9f90c740c8d568e14232..d54499081666d0193dc625d8e2ff848866e76515 100644 (file)
@@ -246,7 +246,8 @@ Augmented assignment is the combination, in a single statement, of a binary
 operation and an assignment statement:
 
 .. productionlist::
-   augmented_assignment_stmt: `target` `augop` (`expression_list` | `yield_expression`)
+   augmented_assignment_stmt: `augtarget` `augop` (`expression_list` | `yield_expression`)
+   augtarget: `identifier` | `attributeref` | `subscription` | `slicing`
    augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
         : | ">>=" | "<<=" | "&=" | "^=" | "|="
 
index 7bb0164a092f472d066f1c90e1fc77fd24c3110a..eaaf257e850d46d561b877b7edd1b4e13de8773f 100755 (executable)
@@ -6,6 +6,9 @@
 #
 # 01/2009, Georg Brandl
 
+# TODO: - wrong versions in versionadded/changed
+#       - wrong markup after versionchanged directive
+
 from __future__ import with_statement
 
 import os
index 54365313b1f3ec2bae9d05bc307baeafdce39f83..a976c8b43c70f14cf8a989b38bdae25f8abbc2f4 100644 (file)
@@ -881,8 +881,8 @@ def formatargspec(args, varargs=None, varkw=None, defaults=None,
     specs = []
     if defaults:
         firstdefault = len(args) - len(defaults)
-    for i in range(len(args)):
-        spec = strseq(args[i], formatargandannotation, join)
+    for i, arg in enumerate(args):
+        spec = strseq(arg, formatargandannotation, join)
         if defaults and i >= firstdefault:
             spec = spec + formatvalue(defaults[i - firstdefault])
         specs.append(spec)
index d1a48688f867e638602e18efe04d5c8bc4d4494f..549a3486d06ed5a6cf3f977787964dcd8c2a2318 100644 (file)
@@ -592,7 +592,7 @@ class CodecCallbackTest(unittest.TestCase):
         encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15")
 
         for res in results:
-            codecs.register_error("test.badhandler", lambda: res)
+            codecs.register_error("test.badhandler", lambda x: res)
             for enc in encs:
                 self.assertRaises(
                     TypeError,
index e3e2344aa6e1dd103121531bbe903e39b06257cf..279b66b473bb7eafe793cab7db7ac17e82670ba9 100644 (file)
@@ -34,7 +34,7 @@
 /* ffi_prep_args is called by the assembly routine once stack space
    has been allocated for the function's arguments */
 
-extern void Py_FatalError(char *msg);
+extern void Py_FatalError(const char *msg);
 
 /*@-exportheader@*/
 void ffi_prep_args(char *stack, extended_cif *ecif)
index 52869cbb67773155ddf88b31f3cb40f9ec941d60..2294500a7898644e8986bd688049ec1c746533c6 100644 (file)
@@ -1923,7 +1923,7 @@ _PyExc_Init(void)
 
     PyExc_MemoryErrorInst = BaseException_new(&_PyExc_MemoryError, NULL, NULL);
     if (!PyExc_MemoryErrorInst)
-        Py_FatalError("Cannot pre-allocate MemoryError instance\n");
+        Py_FatalError("Cannot pre-allocate MemoryError instance");
 
     PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
     if (!PyExc_RecursionErrorInst)
index aaf158f5c505903e9cc68175d33983a6edcea55c..b08cf9b130c39cd2a48d05d346f8ea3b5f3ff1a9 100644 (file)
@@ -191,7 +191,7 @@ num_stmts(const node *n)
         default: {
             char buf[128];
 
-            sprintf(buf, "Non-statement found: %d %d\n",
+            sprintf(buf, "Non-statement found: %d %d",
                     TYPE(n), NCH(n));
             Py_FatalError(buf);
         }
index e50c75cf5c20eee5016ff4e49e07e49434602ec4..7c44f091cefefc265f5baf66f9ae23d1678e23a2 100644 (file)
@@ -1239,7 +1239,7 @@ get_ref_type(struct compiler *c, PyObject *name)
            char buf[350];
            PyOS_snprintf(buf, sizeof(buf),
                          "unknown scope for %.100s in %.100s(%s) in %s\n"
-                         "symbols: %s\nlocals: %s\nglobals: %s\n",
+                         "symbols: %s\nlocals: %s\nglobals: %s",
                          PyBytes_AS_STRING(name), 
                          PyBytes_AS_STRING(c->u->u_name), 
                          PyObject_REPR(c->u->u_ste->ste_id),