Skip to content

Commit 143d034

Browse files
committed
merge 3.2
2 parents c3de6d6 + 7a9953e commit 143d034

File tree

14 files changed

+241
-239
lines changed

14 files changed

+241
-239
lines changed

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ Glossary
365365

366366
iterator
367367
An object representing a stream of data. Repeated calls to the iterator's
368-
:meth:`__next__` method (or passing it to the built-in function
368+
:meth:`~iterator.__next__` method (or passing it to the built-in function
369369
:func:`next`) return successive items in the stream. When no more data
370370
are available a :exc:`StopIteration` exception is raised instead. At this
371371
point, the iterator object is exhausted and any further calls to its

Doc/howto/functional.rst

Lines changed: 171 additions & 180 deletions
Large diffs are not rendered by default.

Doc/library/2to3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Using 2to3
2323
also located in the :file:`Tools/scripts` directory of the Python root.
2424

2525
2to3's basic arguments are a list of files or directories to transform. The
26-
directories are to recursively traversed for Python sources.
26+
directories are recursively traversed for Python sources.
2727

2828
Here is a sample Python 2.x source file, :file:`example.py`::
2929

Doc/library/concurrent.futures.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ Executor Objects
4242

4343
Equivalent to ``map(func, *iterables)`` except *func* is executed
4444
asynchronously and several calls to *func* may be made concurrently. The
45-
returned iterator raises a :exc:`TimeoutError` if :meth:`__next__()` is
46-
called and the result isn't available after *timeout* seconds from the
47-
original call to :meth:`Executor.map`. *timeout* can be an int or a
48-
float. If *timeout* is not specified or ``None``, there is no limit to
49-
the wait time. If a call raises an exception, then that exception will
50-
be raised when its value is retrieved from the iterator.
45+
returned iterator raises a :exc:`TimeoutError` if
46+
:meth:`~iterator.__next__` is called and the result isn't available
47+
after *timeout* seconds from the original call to :meth:`Executor.map`.
48+
*timeout* can be an int or a float. If *timeout* is not specified or
49+
``None``, there is no limit to the wait time. If a call raises an
50+
exception, then that exception will be raised when its value is
51+
retrieved from the iterator.
5152

5253
.. method:: shutdown(wait=True)
5354

@@ -364,10 +365,11 @@ Module Functions
364365
different :class:`Executor` instances) given by *fs* that yields futures as
365366
they complete (finished or were cancelled). Any futures that completed
366367
before :func:`as_completed` is called will be yielded first. The returned
367-
iterator raises a :exc:`TimeoutError` if :meth:`__next__` is called and the
368-
result isn't available after *timeout* seconds from the original call to
369-
:func:`as_completed`. *timeout* can be an int or float. If *timeout* is not
370-
specified or ``None``, there is no limit to the wait time.
368+
iterator raises a :exc:`TimeoutError` if :meth:`~iterator.__next__` is
369+
called and the result isn't available after *timeout* seconds from the
370+
original call to :func:`as_completed`. *timeout* can be an int or float.
371+
If *timeout* is not specified or ``None``, there is no limit to the wait
372+
time.
371373

372374

373375
.. seealso::

Doc/library/dis.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,10 @@ the more significant byte last.
660660

661661
.. opcode:: FOR_ITER (delta)
662662

663-
``TOS`` is an :term:`iterator`. Call its :meth:`__next__` method. If this
664-
yields a new value, push it on the stack (leaving the iterator below it). If
665-
the iterator indicates it is exhausted ``TOS`` is popped, and the byte code
666-
counter is incremented by *delta*.
663+
``TOS`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` method.
664+
If this yields a new value, push it on the stack (leaving the iterator below
665+
it). If the iterator indicates it is exhausted ``TOS`` is popped, and the
666+
byte code counter is incremented by *delta*.
667667

668668

669669
.. opcode:: LOAD_GLOBAL (namei)

Doc/library/functions.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,10 @@ are always available. They are listed here in alphabetical order.
348348
.. function:: enumerate(iterable, start=0)
349349

350350
Return an enumerate object. *iterable* must be a sequence, an
351-
:term:`iterator`, or some other object which supports iteration. The
352-
:meth:`__next__` method of the iterator returned by :func:`enumerate` returns a
353-
tuple containing a count (from *start* which defaults to 0) and the
354-
values obtained from iterating over *iterable*.
351+
:term:`iterator`, or some other object which supports iteration.
352+
The :meth:`~iterator.__next__` method of the iterator returned by
353+
:func:`enumerate` returns a tuple containing a count (from *start* which
354+
defaults to 0) and the values obtained from iterating over *iterable*.
355355

356356
>>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
357357
>>> list(enumerate(seasons))
@@ -683,9 +683,10 @@ are always available. They are listed here in alphabetical order.
683683
starting at ``0``). If it does not support either of those protocols,
684684
:exc:`TypeError` is raised. If the second argument, *sentinel*, is given,
685685
then *object* must be a callable object. The iterator created in this case
686-
will call *object* with no arguments for each call to its :meth:`__next__`
687-
method; if the value returned is equal to *sentinel*, :exc:`StopIteration`
688-
will be raised, otherwise the value will be returned.
686+
will call *object* with no arguments for each call to its
687+
:meth:`~iterator.__next__` method; if the value returned is equal to
688+
*sentinel*, :exc:`StopIteration` will be raised, otherwise the value will
689+
be returned.
689690

690691
One useful application of the second form of :func:`iter` is to read lines of
691692
a file until a certain line is reached. The following example reads a file
@@ -779,9 +780,9 @@ are always available. They are listed here in alphabetical order.
779780

780781
.. function:: next(iterator[, default])
781782

782-
Retrieve the next item from the *iterator* by calling its :meth:`__next__`
783-
method. If *default* is given, it is returned if the iterator is exhausted,
784-
otherwise :exc:`StopIteration` is raised.
783+
Retrieve the next item from the *iterator* by calling its
784+
:meth:`~iterator.__next__` method. If *default* is given, it is returned
785+
if the iterator is exhausted, otherwise :exc:`StopIteration` is raised.
785786

786787

787788
.. function:: object()

Doc/library/stdtypes.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,9 @@ specific sequence types, dictionaries, and other more specialized forms. The
779779
specific types are not important beyond their implementation of the iterator
780780
protocol.
781781

782-
Once an iterator's :meth:`__next__` method raises :exc:`StopIteration`, it must
783-
continue to do so on subsequent calls. Implementations that do not obey this
784-
property are deemed broken.
782+
Once an iterator's :meth:`~iterator.__next__` method raises
783+
:exc:`StopIteration`, it must continue to do so on subsequent calls.
784+
Implementations that do not obey this property are deemed broken.
785785

786786

787787
.. _generator-types:
@@ -792,7 +792,8 @@ Generator Types
792792
Python's :term:`generator`\s provide a convenient way to implement the iterator
793793
protocol. If a container object's :meth:`__iter__` method is implemented as a
794794
generator, it will automatically return an iterator object (technically, a
795-
generator object) supplying the :meth:`__iter__` and :meth:`__next__` methods.
795+
generator object) supplying the :meth:`__iter__` and :meth:`~generator.__next__`
796+
methods.
796797
More information about generators can be found in :ref:`the documentation for
797798
the yield expression <yieldexpr>`.
798799

Doc/reference/datamodel.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,9 @@ Callable types
600600
A function or method which uses the :keyword:`yield` statement (see section
601601
:ref:`yield`) is called a :dfn:`generator function`. Such a function, when
602602
called, always returns an iterator object which can be used to execute the
603-
body of the function: calling the iterator's :meth:`__next__` method will
604-
cause the function to execute until it provides a value using the
605-
:keyword:`yield` statement. When the function executes a
603+
body of the function: calling the iterator's :meth:`iterator__next__`
604+
method will cause the function to execute until it provides a value
605+
using the :keyword:`yield` statement. When the function executes a
606606
:keyword:`return` statement or falls off the end, a :exc:`StopIteration`
607607
exception is raised and the iterator will have reached the end of the set of
608608
values to be returned.
@@ -1189,7 +1189,7 @@ Basic customization
11891189
builtin: print
11901190

11911191
Called by the :func:`format` built-in function (and by extension, the
1192-
:meth:`format` method of class :class:`str`) to produce a "formatted"
1192+
:meth:`str.format` method of class :class:`str`) to produce a "formatted"
11931193
string representation of an object. The ``format_spec`` argument is
11941194
a string that contains a description of the formatting options desired.
11951195
The interpretation of the ``format_spec`` argument is up to the type

Doc/reference/expressions.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ for comprehensions, except that it is enclosed in parentheses instead of
294294
brackets or curly braces.
295295

296296
Variables used in the generator expression are evaluated lazily when the
297-
:meth:`__next__` method is called for generator object (in the same fashion as
298-
normal generators). However, the leftmost :keyword:`for` clause is immediately
299-
evaluated, so that an error produced by it can be seen before any other possible
300-
error in the code that handles the generator expression. Subsequent
301-
:keyword:`for` clauses cannot be evaluated immediately since they may depend on
302-
the previous :keyword:`for` loop. For example: ``(x*y for x in range(10) for y
303-
in bar(x))``.
297+
:meth:`~generator.__next__` method is called for generator object (in the same
298+
fashion as normal generators). However, the leftmost :keyword:`for` clause is
299+
immediately evaluated, so that an error produced by it can be seen before any
300+
other possible error in the code that handles the generator expression.
301+
Subsequent :keyword:`for` clauses cannot be evaluated immediately since they
302+
may depend on the previous :keyword:`for` loop. For example: ``(x*y for x in
303+
range(10) for y in bar(x))``.
304304

305305
The parentheses can be omitted on calls with only one argument. See section
306306
:ref:`calls` for the detail.
@@ -394,10 +394,11 @@ is already executing raises a :exc:`ValueError` exception.
394394

395395
Starts the execution of a generator function or resumes it at the last
396396
executed :keyword:`yield` expression. When a generator function is resumed
397-
with a :meth:`__next__` method, the current :keyword:`yield` expression
398-
always evaluates to :const:`None`. The execution then continues to the next
399-
:keyword:`yield` expression, where the generator is suspended again, and the
400-
value of the :token:`expression_list` is returned to :meth:`next`'s caller.
397+
with a :meth:`~generator.__next__` method, the current :keyword:`yield`
398+
expression always evaluates to :const:`None`. The execution then continues
399+
to the next :keyword:`yield` expression, where the generator is suspended
400+
again, and the value of the :token:`expression_list` is returned to
401+
:meth:`next`'s caller.
401402
If the generator exits without yielding another value, a :exc:`StopIteration`
402403
exception is raised.
403404

Doc/tutorial/classes.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,11 @@ using a :keyword:`for` statement::
737737
This style of access is clear, concise, and convenient. The use of iterators
738738
pervades and unifies Python. Behind the scenes, the :keyword:`for` statement
739739
calls :func:`iter` on the container object. The function returns an iterator
740-
object that defines the method :meth:`__next__` which accesses elements in the
741-
container one at a time. When there are no more elements, :meth:`__next__`
742-
raises a :exc:`StopIteration` exception which tells the :keyword:`for` loop to
743-
terminate. You can call the :meth:`__next__` method using the :func:`next`
744-
built-in function; this example shows how it all works::
740+
object that defines the method :meth:`~iterator.__next__` which accesses
741+
elements in the container one at a time. When there are no more elements,
742+
:meth:`__next__` raises a :exc:`StopIteration` exception which tells the
743+
:keyword:`for` loop to terminate. You can call the :meth:`__next__` method
744+
using the :func:`next` built-in function; this example shows how it all works::
745745

746746
>>> s = 'abc'
747747
>>> it = iter(s)
@@ -761,8 +761,8 @@ built-in function; this example shows how it all works::
761761

762762
Having seen the mechanics behind the iterator protocol, it is easy to add
763763
iterator behavior to your classes. Define an :meth:`__iter__` method which
764-
returns an object with a :meth:`__next__` method. If the class defines
765-
:meth:`__next__`, then :meth:`__iter__` can just return ``self``::
764+
returns an object with a :meth:`~iterator.__next__` method. If the class
765+
defines :meth:`__next__`, then :meth:`__iter__` can just return ``self``::
766766

767767
class Reverse:
768768
"""Iterator for looping over a sequence backwards."""
@@ -819,8 +819,8 @@ easy to create::
819819

820820
Anything that can be done with generators can also be done with class based
821821
iterators as described in the previous section. What makes generators so
822-
compact is that the :meth:`__iter__` and :meth:`__next__` methods are created
823-
automatically.
822+
compact is that the :meth:`__iter__` and :meth:`~generator.__next__` methods
823+
are created automatically.
824824

825825
Another key feature is that the local variables and execution state are
826826
automatically saved between calls. This made the function easier to write and

0 commit comments

Comments
 (0)