Skip to content

Commit 1c5672f

Browse files
committed
Merged revisions 70507-70508 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r70507 | benjamin.peterson | 2009-03-21 12:31:58 -0500 (Sat, 21 Mar 2009) | 75 lines Merged revisions 70342,70385-70387,70389-70390,70392-70393,70395,70400,70405-70406,70418,70438,70464,70468 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70342 | georg.brandl | 2009-03-13 14:03:58 -0500 (Fri, 13 Mar 2009) | 1 line python#5486: typos. ........ r70385 | benjamin.peterson | 2009-03-15 09:38:55 -0500 (Sun, 15 Mar 2009) | 1 line fix tuple.index() error message python#5495 ........ r70386 | georg.brandl | 2009-03-15 16:32:06 -0500 (Sun, 15 Mar 2009) | 1 line python#5496: fix docstring of lookup(). ........ r70387 | georg.brandl | 2009-03-15 16:37:16 -0500 (Sun, 15 Mar 2009) | 1 line python#5493: clarify __nonzero__ docs. ........ r70389 | georg.brandl | 2009-03-15 16:43:38 -0500 (Sun, 15 Mar 2009) | 1 line Fix a small nit in the error message if bool() falls back on __len__ and it returns the wrong type: it would tell the user that __nonzero__ should return bool or int. ........ r70390 | georg.brandl | 2009-03-15 16:44:43 -0500 (Sun, 15 Mar 2009) | 1 line python#5491: clarify nested() semantics. ........ r70392 | georg.brandl | 2009-03-15 16:46:00 -0500 (Sun, 15 Mar 2009) | 1 line python#5488: add missing struct member. ........ r70393 | georg.brandl | 2009-03-15 16:47:42 -0500 (Sun, 15 Mar 2009) | 1 line python#5478: fix copy-paste oversight in function signature. ........ r70395 | georg.brandl | 2009-03-15 16:51:48 -0500 (Sun, 15 Mar 2009) | 1 line python#5276: document IDLESTARTUP and .Idle.py. ........ r70400 | georg.brandl | 2009-03-15 16:59:37 -0500 (Sun, 15 Mar 2009) | 3 lines Fix markup in re docs and give a mail address in regex howto, so that the recommendation to send suggestions to the author can be followed. ........ r70405 | georg.brandl | 2009-03-15 17:11:07 -0500 (Sun, 15 Mar 2009) | 7 lines Move the previously local import of threading to module level. This is cleaner and avoids lockups in obscure cases where a Queue is instantiated while the import lock is already held by another thread. OKed by Tim Peters. ........ r70406 | hirokazu.yamamoto | 2009-03-15 17:43:14 -0500 (Sun, 15 Mar 2009) | 1 line Added skip for old MSVC. ........ r70418 | georg.brandl | 2009-03-16 14:42:03 -0500 (Mon, 16 Mar 2009) | 1 line Add token markup. ........ r70438 | benjamin.peterson | 2009-03-17 15:29:51 -0500 (Tue, 17 Mar 2009) | 1 line I thought this was begging for an example ........ r70464 | benjamin.peterson | 2009-03-18 15:58:09 -0500 (Wed, 18 Mar 2009) | 1 line a much better example ........ r70468 | benjamin.peterson | 2009-03-18 22:04:31 -0500 (Wed, 18 Mar 2009) | 1 line close files after comparing them ........ ................ r70508 | benjamin.peterson | 2009-03-21 12:36:10 -0500 (Sat, 21 Mar 2009) | 1 line port the queue change r70405 ................
1 parent 915ce33 commit 1c5672f

14 files changed

Lines changed: 70 additions & 39 deletions

File tree

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ Number Object Structures
10521052
binaryfunc nb_inplace_add;
10531053
binaryfunc nb_inplace_subtract;
10541054
binaryfunc nb_inplace_multiply;
1055+
binaryfunc nb_inplace_divide;
10551056
binaryfunc nb_inplace_remainder;
10561057
ternaryfunc nb_inplace_power;
10571058
binaryfunc nb_inplace_lshift;

Doc/howto/regex.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Regular Expression HOWTO
55
****************************
66

7-
:Author: A.M. Kuchling
7+
:Author: A.M. Kuchling <amk@amk.ca>
88
:Release: 0.05
99

1010
.. TODO:

Doc/library/contextlib.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ Functions provided:
6161

6262
from contextlib import nested
6363

64-
with nested(A, B, C) as (X, Y, Z):
64+
with nested(A(), B(), C()) as (X, Y, Z):
6565
do_something()
6666

6767
is equivalent to this::
6868

69-
with A as X:
70-
with B as Y:
71-
with C as Z:
69+
m1, m2, m3 = A(), B(), C()
70+
with m1 as X:
71+
with m2 as Y:
72+
with m3 as Z:
7273
do_something()
7374

7475
Note that if the :meth:`__exit__` method of one of the nested context managers

Doc/library/functions.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,14 @@ are always available. They are listed here in alphabetical order.
560560
its :meth:`__next__` method; if the value returned is equal to *sentinel*,
561561
:exc:`StopIteration` will be raised, otherwise the value will be returned.
562562

563+
One useful application of the second form of :func:`iter` is to read lines of
564+
a file until a certain line is reached. The following example reads a file
565+
until ``"STOP"`` is reached: ::
566+
567+
with open("mydata.txt") as fp:
568+
for line in iter(fp.readline, "STOP"):
569+
process_line(line)
570+
563571

564572
.. function:: len(s)
565573

Doc/library/idle.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,24 @@ Shell colors:
253253
black
254254

255255

256+
Startup
257+
-------
258+
259+
Upon startup with the ``-s`` option, IDLE will execute the file referenced by
260+
the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
261+
Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
262+
referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for
263+
``PYTHONSTARTUP``. Files referenced by these environment variables are
264+
convenient places to store functions that are used frequently from the Idle
265+
shell, or for executing import statements to import common modules.
266+
267+
In addition, ``Tk`` also loads a startup file if it is present. Note that the
268+
Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
269+
looked for in the user's home directory. Statements in this file will be
270+
executed in the Tk namespace, so this file is not useful for importing functions
271+
to be used from Idle's Python shell.
272+
273+
256274
Command line usage
257275
^^^^^^^^^^^^^^^^^^
258276

Doc/library/re.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ For example:
11141114
string)`` or ``re.search(pattern, string)``.
11151115

11161116
:func:`match` has an optional second parameter that gives an index in the string
1117-
where the search is to start:
1117+
where the search is to start::
11181118

11191119
>>> pattern = re.compile("o")
11201120
>>> pattern.match("dog") # No match as "o" is not at the start of "dog."

Doc/library/string.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ The grammar for a replacement field is as follows:
196196

197197
.. productionlist:: sf
198198
replacement_field: "{" `field_name` ["!" `conversion`] [":" `format_spec`] "}"
199-
field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" element_index "]")*
199+
field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" `element_index` "]")*
200200
attribute_name: `identifier`
201201
element_index: `integer`
202202
conversion: "r" | "s" | "a"

Doc/library/xml.dom.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ of that class.
600600
Same as equivalent method in the :class:`Document` class.
601601

602602

603-
.. method:: Element.getElementsByTagNameNS(tagName)
603+
.. method:: Element.getElementsByTagNameNS(namespaceURI, localName)
604604

605605
Same as equivalent method in the :class:`Document` class.
606606

Doc/reference/datamodel.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,11 +1248,12 @@ Basic customization
12481248

12491249
.. index:: single: __len__() (mapping object method)
12501250

1251-
Called to implement truth value testing, and the built-in operation ``bool()``;
1252-
should return ``False`` or ``True``. When this method is not defined,
1253-
:meth:`__len__` is called, if it is defined (see below) and ``True`` is returned
1254-
when the length is not zero. If a class defines neither :meth:`__len__` nor
1255-
:meth:`__bool__`, all its instances are considered true.
1251+
Called to implement truth value testing and the built-in operation
1252+
``bool()``; should return ``False`` or ``True``, or their integer equivalents
1253+
``0`` or ``1``. When this method is not defined, :meth:`__len__` is called,
1254+
if it is defined, and the object is considered true if its result is nonzero.
1255+
If a class defines neither :meth:`__len__` nor :meth:`__bool__`, all its
1256+
instances are considered true.
12561257

12571258

12581259
.. _attribute-access:

Lib/filecmp.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import os
1313
import stat
14+
import contextlib
1415
from itertools import filterfalse
1516

1617
__all__ = ["cmp","dircmp","cmpfiles"]
@@ -62,15 +63,14 @@ def _sig(st):
6263

6364
def _do_cmp(f1, f2):
6465
bufsize = BUFSIZE
65-
fp1 = open(f1, 'rb')
66-
fp2 = open(f2, 'rb')
67-
while True:
68-
b1 = fp1.read(bufsize)
69-
b2 = fp2.read(bufsize)
70-
if b1 != b2:
71-
return False
72-
if not b1:
73-
return True
66+
with contextlib.nested(open(f1, 'rb'), open(f2, 'rb')) as (fp1, fp2):
67+
while True:
68+
b1 = fp1.read(bufsize)
69+
b2 = fp2.read(bufsize)
70+
if b1 != b2:
71+
return False
72+
if not b1:
73+
return True
7474

7575
# Directory comparison class.
7676
#

0 commit comments

Comments
 (0)