Commits

georg.brandl  committed 6f0853f

Fixes for bugs found by Tim Hatch.

  • Participants
  • Parent commits a922f56

Comments (0)

Files changed (19)

 * Manus Hand
 * Gerhard Häring
 * Travis B. Hartwell
+* Tim Hatch
 * Janko Hauser
 * Bernhard Herzog
 * Magnus L. Hetland

File Doc-26/library/array.rst

 
 .. method:: array.fromunicode(s)
 
-   Extends this array with data from the given unicode string.  The array must be a
-   type ``'u'`` array; otherwise a :exc:`ValueError` is raised.  Use
-   ``array.fromstring(ustr.decode(enc))`` to append Unicode data to an array of
-   some other type.
+   Extends this array with data from the given unicode string.  The array must
+   be a type ``'u'`` array; otherwise a :exc:`ValueError` is raised.  Use
+   ``array.fromstring(unicodestring.encode(enc))`` to append Unicode data to an
+   array of some other type.
 
 
 .. method:: array.index(x)
 ``array(typecode, initializer)``.  The *initializer* is omitted if the array is
 empty, otherwise it is a string if the *typecode* is ``'c'``, otherwise it is a
 list of numbers.  The string is guaranteed to be able to be converted back to an
-array with the same type and value using reverse quotes (``````), so long as the
+array with the same type and value using :func:`eval`, so long as the
 :func:`array` function has been imported using ``from array import array``.
 Examples::
 
    array('l')
    array('c', 'hello world')
-   array('u', u'hello \textbackslash u2641')
+   array('u', u'hello \u2641')
    array('l', [1, 2, 3, 4, 5])
    array('d', [1.0, 2.0, 3.14])
 

File Doc-26/library/calendar.rst

 
 .. function:: leapdays(y1, y2)
 
-   Returns the number of leap years in the range [*y1*...*y2*), where *y1* and *y2*
-   are years.
+   Returns the number of leap years in the range from *y1* to *y2* (exclusive),
+   where *y1* and *y2* are years.
 
    .. versionchanged:: 2.0
-      This function didn't work for ranges spanning  a century change in Python 1.5.2.
+      This function didn't work for ranges spanning a century change in Python
+      1.5.2.
 
 
 .. function:: weekday(year, month, day)
 
-   Returns the day of the week (``0`` is Monday) for *year* (``1970``\ --...),
-   *month* (``1``\ --\ ``12``), *day* (``1``\ --\ ``31``).
+   Returns the day of the week (``0`` is Monday) for *year* (``1970``--...),
+   *month* (``1``--``12``), *day* (``1``--``31``).
 
 
 .. function:: weekheader(n)

File Doc-26/library/collections.rst

 ordered dictionaries.
 
 .. versionchanged:: 2.5
-   Added defaultdict.
+   Added :class:`defaultdict`.
 
 .. versionchanged:: 2.6
-   Added NamedTuple.
+   Added :class:`NamedTuple`.
 
 
 .. _deque-objects:
    Deques are a generalization of stacks and queues (the name is pronounced "deck"
    and is short for "double-ended queue").  Deques support thread-safe, memory
    efficient appends and pops from either side of the deque with approximately the
-   same ``O(1)`` performance in either direction.
+   same O(1) performance in either direction.
 
    Though :class:`list` objects support similar operations, they are optimized for
-   fast fixed-length operations and incur ``O(n)`` memory movement costs for
+   fast fixed-length operations and incur O(n) memory movement costs for
    ``pop(0)`` and ``insert(0, v)`` operations which change both the size and
    position of the underlying data representation.
 
 :meth:`popleft` to select the current task and :meth:`append` to add it back to
 the tasklist if the input stream is not exhausted::
 
-   def roundrobin(*iterables):
-       pending = deque(iter(i) for i in iterables)
-       while pending:
-           task = pending.popleft()
-           try:
-               yield task.next()
-           except StopIteration:
-               continue
-           pending.append(task)
-
+   >>> def roundrobin(*iterables):
+   ...     pending = deque(iter(i) for i in iterables)
+   ...     while pending:
+   ...         task = pending.popleft()
+   ...         try:
+   ...             yield task.next()
+   ...         except StopIteration:
+   ...             continue
+   ...         pending.append(task)
+   ...
    >>> for value in roundrobin('abc', 'd', 'efgh'):
    ...     print value
 
 For example, building a balanced binary tree of nested lists entails reducing
 two adjacent nodes into one by grouping them in a list::
 
-   def maketree(iterable):
-       d = deque(iterable)
-       while len(d) > 1:
-           pair = [d.popleft(), d.popleft()]
-           d.append(pair)
-       return list(d)
-
+   >>> def maketree(iterable):
+   ...     d = deque(iterable)
+   ...     while len(d) > 1:
+   ...         pair = [d.popleft(), d.popleft()]
+   ...         d.append(pair)
+   ...     return list(d)
+   ...
    >>> print maketree('abcdefgh')
    [[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]]
 
    >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
    >>> d = defaultdict(list)
    >>> for k, v in s:
-           d[k].append(v)
-
+   ...     d[k].append(v)
+   ...
    >>> d.items()
    [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
 
 
    >>> d = {}
    >>> for k, v in s:
-   	d.setdefault(k, []).append(v)
-
+   ...     d.setdefault(k, []).append(v)
+   ...
    >>> d.items()
    [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
 
    >>> s = 'mississippi'
    >>> d = defaultdict(int)
    >>> for k in s:
-           d[k] += 1
-
+   ...     d[k] += 1
+   ...
    >>> d.items()
    [('i', 4), ('p', 2), ('s', 4), ('m', 1)]
 
    >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)]
    >>> d = defaultdict(set)
    >>> for k, v in s:
-           d[k].add(v)
-
+   ...     d[k].add(v)
+   ...
    >>> d.items()
    [('blue', set([2, 4])), ('red', set([1, 3]))]
 

File Doc-26/library/pprint.rst

    controlled by *depth*; if the data structure being printed is too deep, the next
    contained level is replaced by ``...``.  By default, there is no constraint on
    the depth of the objects being formatted.  The desired output width is
-   constrained using the *width* parameter; the default is eighty characters.  If a
+   constrained using the *width* parameter; the default is 80 characters.  If a
    structure cannot be formatted within the constrained width, a best effort will
    be made. ::
 

File Doc-26/library/queue.rst

    ignored in that case).
 
    .. versionadded:: 2.3
-      the timeout parameter.
+      The *timeout* parameter.
 
 
 .. method:: Queue.put_nowait(item)
    else raise the :exc:`Empty` exception (*timeout* is ignored in that case).
 
    .. versionadded:: 2.3
-      the timeout parameter.
+      The *timeout* parameter.
 
 
 .. method:: Queue.get_nowait()

File Doc-26/library/repr.rst

    with ``level - 1`` for the value of *level* in the recursive  call.
 
 
-.. method:: Repr.repr_type(obj, level)
+.. method:: Repr.repr_TYPE(obj, level)
    :noindex:
 
    Formatting methods for specific types are implemented as methods with a name
-   based on the type name.  In the method name, *type* is replaced by
+   based on the type name.  In the method name, **TYPE** is replaced by
    ``string.join(string.split(type(obj).__name__, '_'))``. Dispatch to these
    methods is handled by :meth:`repr1`. Type-specific methods which need to
    recursively format a value should call ``self.repr1(subobj, level - 1)``.

File Doc-26/library/sets.rst

 | ``s.issuperset(t)``           | ``s >= t`` | test whether every element in   |
 |                               |            | *t* is in *s*                   |
 +-------------------------------+------------+---------------------------------+
-| ``s.union(t)``                | *s* \| *t* | new set with elements from both |
+| ``s.union(t)``                | ``s | t``  | new set with elements from both |
 |                               |            | *s* and *t*                     |
 +-------------------------------+------------+---------------------------------+
-| ``s.intersection(t)``         | *s* & *t*  | new set with elements common to |
+| ``s.intersection(t)``         | ``s & t``  | new set with elements common to |
 |                               |            | *s* and *t*                     |
 +-------------------------------+------------+---------------------------------+
-| ``s.difference(t)``           | *s* - *t*  | new set with elements in *s*    |
+| ``s.difference(t)``           | ``s - t``  | new set with elements in *s*    |
 |                               |            | but not in *t*                  |
 +-------------------------------+------------+---------------------------------+
-| ``s.symmetric_difference(t)`` | *s* ^ *t*  | new set with elements in either |
+| ``s.symmetric_difference(t)`` | ``s ^ t``  | new set with elements in either |
 |                               |            | *s* or *t* but not both         |
 +-------------------------------+------------+---------------------------------+
 | ``s.copy()``                  |            | new set with a shallow copy of  |
 * The built-in versions do not have a :meth:`union_update` method. Instead, use
   the :meth:`update` method which is equivalent.
 
-* The built-in versions do not have a :meth:`_repr(sorted=True)` method.
+* The built-in versions do not have a ``_repr(sorted=True)`` method.
   Instead, use the built-in :func:`repr` and :func:`sorted` functions:
   ``repr(sorted(s))``.
 

File Doc-26/library/types.rst

 
    .. index:: builtin: type
 
-   The type of type objects (such as returned by :func:`type`).
+   The type of type objects (such as returned by :func:`type`); alias of the
+   built-in :class:`type`.
 
 
 .. data:: BooleanType
 
-   The type of the :class:`bool` values ``True`` and ``False``; this is an alias of
-   the built-in :func:`bool` function.
+   The type of the :class:`bool` values ``True`` and ``False``; alias of the
+   built-in :class:`bool`.
 
    .. versionadded:: 2.3
 
 
 .. data:: IntType
 
-   The type of integers (e.g. ``1``).
+   The type of integers (e.g. ``1``); alias of the built-in :class:`int`.
 
 
 .. data:: LongType
 
-   The type of long integers (e.g. ``1L``).
+   The type of long integers (e.g. ``1L``); alias of the built-in :class:`long`.
 
 
 .. data:: FloatType
 
-   The type of floating point numbers (e.g. ``1.0``).
+   The type of floating point numbers (e.g. ``1.0``); alias of the built-in
+   :class:`float`.
 
 
 .. data:: ComplexType
 
 .. data:: StringType
 
-   The type of character strings (e.g. ``'Spam'``).
+   The type of character strings (e.g. ``'Spam'``); alias of the built-in
+   :class:`str`.
 
 
 .. data:: UnicodeType
 
    The type of Unicode character strings (e.g. ``u'Spam'``).  This is not defined
-   if Python was built without Unicode support.
+   if Python was built without Unicode support.  It's an alias of the built-in
+   :class:`unicode`.
 
 
 .. data:: TupleType
 
-   The type of tuples (e.g. ``(1, 2, 3, 'Spam')``).
+   The type of tuples (e.g. ``(1, 2, 3, 'Spam')``); alias of the built-in
+   :class:`tuple`.
 
 
 .. data:: ListType
 
-   The type of lists (e.g. ``[0, 1, 2, 3]``).
+   The type of lists (e.g. ``[0, 1, 2, 3]``); alias of the built-in
+   :class:`list`.
 
 
 .. data:: DictType
 
-   The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``).
+   The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``); alias of the
+   built-in :class:`dict`.
 
 
 .. data:: DictionaryType
 
 .. data:: FileType
 
-   The type of open file objects such as ``sys.stdout``.
+   The type of open file objects such as ``sys.stdout``; alias of the built-in
+   :class:`file`.
 
 
 .. data:: XRangeType
 
    .. index:: builtin: xrange
 
-   The type of range objects returned by :func:`xrange`.
+   The type of range objects returned by :func:`xrange`; alias of the built-in
+   :class:`xrange`.
 
 
 .. data:: SliceType
 
    .. index:: builtin: slice
 
-   The type of objects returned by :func:`slice`.
+   The type of objects returned by :func:`slice`; alias of the built-in
+   :class:`slice`.
 
 
 .. data:: EllipsisType
    example: ``isinstance(s, types.StringTypes)``.
 
    .. versionadded:: 2.2
-

File Doc-26/library/userdict.rst

    Class that simulates a list.  The instance's contents are kept in a regular
    list, which is accessible via the :attr:`data` attribute of :class:`UserList`
    instances.  The instance's contents are initially set to a copy of *list*,
-   defaulting to the empty list ``[]``.  *list* can be either a regular Python
-   list, or an instance of :class:`UserList` (or a subclass).
+   defaulting to the empty list ``[]``.  *list* can be any iterable, e.g. a
+   real Python list or a :class:`UserList` object.
 
 In addition to supporting the methods and operations of mutable sequences (see
 section :ref:`typesseq`), :class:`UserList` instances provide the following
 * Manus Hand
 * Gerhard Häring
 * Travis B. Hartwell
+* Tim Hatch
 * Janko Hauser
 * Bernhard Herzog
 * Magnus L. Hetland

File Doc-3k/library/array.rst

 
 .. method:: array.fromunicode(s)
 
-   Extends this array with data from the given unicode string.  The array must be a
-   type ``'u'`` array; otherwise a :exc:`ValueError` is raised.  Use
-   ``array.fromstring(ustr.decode(enc))`` to append Unicode data to an array of
-   some other type.
+   Extends this array with data from the given unicode string.  The array must
+   be a type ``'u'`` array; otherwise a :exc:`ValueError` is raised.  Use
+   ``array.fromstring(unicodestring.encode(enc))`` to append Unicode data to an
+   array of some other type.
 
 
 .. method:: array.index(x)
 ``array(typecode, initializer)``.  The *initializer* is omitted if the array is
 empty, otherwise it is a string if the *typecode* is ``'c'``, otherwise it is a
 list of numbers.  The string is guaranteed to be able to be converted back to an
-array with the same type and value using reverse quotes (``````), so long as the
+array with the same type and value using :func:`eval`, so long as the
 :func:`array` function has been imported using ``from array import array``.
 Examples::
 
    array('l')
    array('c', 'hello world')
-   array('u', u'hello \textbackslash u2641')
+   array('u', u'hello \u2641')
    array('l', [1, 2, 3, 4, 5])
    array('d', [1.0, 2.0, 3.14])
 

File Doc-3k/library/calendar.rst

 
 .. function:: leapdays(y1, y2)
 
-   Returns the number of leap years in the range [*y1*...*y2*), where *y1* and *y2*
-   are years.
+   Returns the number of leap years in the range from *y1* to *y2* (exclusive),
+   where *y1* and *y2* are years.
 
    .. versionchanged:: 2.0
-      This function didn't work for ranges spanning  a century change in Python 1.5.2.
+      This function didn't work for ranges spanning a century change in Python
+      1.5.2.
 
 
 .. function:: weekday(year, month, day)
 
-   Returns the day of the week (``0`` is Monday) for *year* (``1970``\ --...),
-   *month* (``1``\ --\ ``12``), *day* (``1``\ --\ ``31``).
+   Returns the day of the week (``0`` is Monday) for *year* (``1970``--...),
+   *month* (``1``--``12``), *day* (``1``--``31``).
 
 
 .. function:: weekheader(n)

File Doc-3k/library/collections.rst

 ordered dictionaries.
 
 .. versionchanged:: 2.5
-   Added defaultdict.
+   Added :class:`defaultdict`.
 
 .. versionchanged:: 2.6
-   Added NamedTuple.
+   Added :class:`NamedTuple`.
 
 
 .. _deque-objects:
    Deques are a generalization of stacks and queues (the name is pronounced "deck"
    and is short for "double-ended queue").  Deques support thread-safe, memory
    efficient appends and pops from either side of the deque with approximately the
-   same ``O(1)`` performance in either direction.
+   same O(1) performance in either direction.
 
    Though :class:`list` objects support similar operations, they are optimized for
-   fast fixed-length operations and incur ``O(n)`` memory movement costs for
+   fast fixed-length operations and incur O(n) memory movement costs for
    ``pop(0)`` and ``insert(0, v)`` operations which change both the size and
    position of the underlying data representation.
 
 :meth:`popleft` to select the current task and :meth:`append` to add it back to
 the tasklist if the input stream is not exhausted::
 
-   def roundrobin(*iterables):
-       pending = deque(iter(i) for i in iterables)
-       while pending:
-           task = pending.popleft()
-           try:
-               yield next(task)
-           except StopIteration:
-               continue
-           pending.append(task)
-
+   >>> def roundrobin(*iterables):
+   ...     pending = deque(iter(i) for i in iterables)
+   ...     while pending:
+   ...         task = pending.popleft()
+   ...         try:
+   ...             yield next(task)
+   ...         except StopIteration:
+   ...             continue
+   ...         pending.append(task)
+   ...
    >>> for value in roundrobin('abc', 'd', 'efgh'):
    ...     print value
 
 For example, building a balanced binary tree of nested lists entails reducing
 two adjacent nodes into one by grouping them in a list::
 
-   def maketree(iterable):
-       d = deque(iterable)
-       while len(d) > 1:
-           pair = [d.popleft(), d.popleft()]
-           d.append(pair)
-       return list(d)
-
+   >>> def maketree(iterable):
+   ...     d = deque(iterable)
+   ...     while len(d) > 1:
+   ...         pair = [d.popleft(), d.popleft()]
+   ...         d.append(pair)
+   ...     return list(d)
+   ...
    >>> print maketree('abcdefgh')
    [[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]]
 
    >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
    >>> d = defaultdict(list)
    >>> for k, v in s:
-           d[k].append(v)
-
+   ...     d[k].append(v)
+   ...
    >>> d.items()
    [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
 
 
    >>> d = {}
    >>> for k, v in s:
-   	d.setdefault(k, []).append(v)
-
+   ...     d.setdefault(k, []).append(v)
+   ...
    >>> d.items()
    [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
 
    >>> s = 'mississippi'
    >>> d = defaultdict(int)
    >>> for k in s:
-           d[k] += 1
-
+   ...     d[k] += 1
+   ...
    >>> d.items()
    [('i', 4), ('p', 2), ('s', 4), ('m', 1)]
 
    >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)]
    >>> d = defaultdict(set)
    >>> for k, v in s:
-           d[k].add(v)
-
+   ...     d[k].add(v)
+   ...
    >>> d.items()
    [('blue', set([2, 4])), ('red', set([1, 3]))]
 

File Doc-3k/library/pprint.rst

    controlled by *depth*; if the data structure being printed is too deep, the next
    contained level is replaced by ``...``.  By default, there is no constraint on
    the depth of the objects being formatted.  The desired output width is
-   constrained using the *width* parameter; the default is eighty characters.  If a
+   constrained using the *width* parameter; the default is 80 characters.  If a
    structure cannot be formatted within the constrained width, a best effort will
    be made. ::
 

File Doc-3k/library/queue.rst

    ignored in that case).
 
    .. versionadded:: 2.3
-      the timeout parameter.
+      The *timeout* parameter.
 
 
 .. method:: Queue.put_nowait(item)
    else raise the :exc:`Empty` exception (*timeout* is ignored in that case).
 
    .. versionadded:: 2.3
-      the timeout parameter.
+      The *timeout* parameter.
 
 
 .. method:: Queue.get_nowait()

File Doc-3k/library/repr.rst

    with ``level - 1`` for the value of *level* in the recursive  call.
 
 
-.. method:: Repr.repr_type(obj, level)
+.. method:: Repr.repr_TYPE(obj, level)
    :noindex:
 
    Formatting methods for specific types are implemented as methods with a name
-   based on the type name.  In the method name, *type* is replaced by
+   based on the type name.  In the method name, **TYPE** is replaced by
    ``string.join(string.split(type(obj).__name__, '_'))``. Dispatch to these
    methods is handled by :meth:`repr1`. Type-specific methods which need to
    recursively format a value should call ``self.repr1(subobj, level - 1)``.

File Doc-3k/library/types.rst

 
    .. index:: builtin: type
 
-   The type of type objects (such as returned by :func:`type`).
+   The type of type objects (such as returned by :func:`type`); alias of the
+   built-in :class:`type`.
 
 
 .. data:: BooleanType
 
-   The type of the :class:`bool` values ``True`` and ``False``; this is an alias of
-   the built-in :func:`bool` function.
+   The type of the :class:`bool` values ``True`` and ``False``; alias of the
+   built-in :class:`bool`.
 
    .. versionadded:: 2.3
 
 
 .. data:: IntType
 
-   The type of integers (e.g. ``1``).
+   The type of integers (e.g. ``1``); alias of the built-in :class:`int`.
 
 
 .. data:: LongType
 
-   The type of long integers (e.g. ``1L``).
+   The type of long integers (e.g. ``1L``); alias of the built-in :class:`long`.
 
 
 .. data:: FloatType
 
-   The type of floating point numbers (e.g. ``1.0``).
+   The type of floating point numbers (e.g. ``1.0``); alias of the built-in
+   :class:`float`.
 
 
 .. data:: ComplexType
 
 .. data:: StringType
 
-   The type of character strings (e.g. ``'Spam'``).
+   The type of character strings (e.g. ``'Spam'``); alias of the built-in
+   :class:`str`.
 
 
 .. data:: UnicodeType
 
    The type of Unicode character strings (e.g. ``u'Spam'``).  This is not defined
-   if Python was built without Unicode support.
+   if Python was built without Unicode support.  It's an alias of the built-in
+   :class:`unicode`.
 
 
 .. data:: TupleType
 
-   The type of tuples (e.g. ``(1, 2, 3, 'Spam')``).
+   The type of tuples (e.g. ``(1, 2, 3, 'Spam')``); alias of the built-in
+   :class:`tuple`.
 
 
 .. data:: ListType
 
-   The type of lists (e.g. ``[0, 1, 2, 3]``).
+   The type of lists (e.g. ``[0, 1, 2, 3]``); alias of the built-in
+   :class:`list`.
 
 
 .. data:: DictType
 
-   The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``).
+   The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``); alias of the
+   built-in :class:`dict`.
 
 
 .. data:: DictionaryType
 
 .. data:: FileType
 
-   The type of open file objects such as ``sys.stdout``.
+   The type of open file objects such as ``sys.stdout``; alias of the built-in
+   :class:`file`.
 
 
 .. data:: RangeType
 
    .. index:: builtin: range
 
-   The type of range objects returned by :func:`range`.
+   The type of range objects returned by :func:`range`; alias of the built-in
+   :class:`range`.
 
 
 .. data:: SliceType
 
    .. index:: builtin: slice
 
-   The type of objects returned by :func:`slice`.
+   The type of objects returned by :func:`slice`; alias of the built-in
+   :class:`slice`.
 
 
 .. data:: EllipsisType
    example: ``isinstance(s, types.StringTypes)``.
 
    .. versionadded:: 2.2
-

File Doc-3k/library/userdict.rst

    Class that simulates a list.  The instance's contents are kept in a regular
    list, which is accessible via the :attr:`data` attribute of :class:`UserList`
    instances.  The instance's contents are initially set to a copy of *list*,
-   defaulting to the empty list ``[]``.  *list* can be either a regular Python
-   list, or an instance of :class:`UserList` (or a subclass).
+   defaulting to the empty list ``[]``.  *list* can be any iterable, e.g. a
+   real Python list or a :class:`UserList` object.
 
 In addition to supporting the methods and operations of mutable sequences (see
 section :ref:`typesseq`), :class:`UserList` instances provide the following