[Python-checkins] r71282 - in python/branches/release26-maint: Doc/c-api/typeobj.rst Doc/distutils/packageindex.rst Doc/howto/regex.rst Doc/library/2to3.rst Doc/library/abc.rst Doc/library/contextlib.rst Doc/library/exceptions.rst Doc/library/filecmp.rst Doc/library/idle.rst Doc/library/re.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/sys.rst Doc/library/threading.rst Doc/library/time.rst Doc/library/turtle.rst Doc/library/xml.dom.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/whatsnew/2.6.rst Lib/test/test_struct.py Modules/_codecsmodule.c Modules/_ctypes/_ctypes.c Objects/typeobject.c Objects/unicodeobject.c

georg.brandl python-checkins at python.org
Sun Apr 5 23:48:07 CEST 2009


Author: georg.brandl
Date: Sun Apr 5 23:48:06 2009
New Revision: 71282
Log:
Merged revisions 69578-69580,69901,69907,69994,70022-70023,70025-70026,70166,70273,70275,70342,70386-70387,70389-70390,70392-70393,70395,70397,70400,70418 via svnmerge
........
 r69578 | georg.brandl | 2009年02月13日 12:03:59 +0100 (Fr, 13 Feb 2009) | 1 line
 
 #3694: add test for fix committed in r66693.
........
 r69579 | georg.brandl | 2009年02月13日 12:06:59 +0100 (Fr, 13 Feb 2009) | 2 lines
 
 Fix warnings GCC emits where the argument of PyErr_Format is a single variable.
........
 r69580 | georg.brandl | 2009年02月13日 12:10:04 +0100 (Fr, 13 Feb 2009) | 2 lines
 
 Fix warnings GCC emits where the argument of PyErr_Format is a single variable.
........
 r69901 | georg.brandl | 2009年02月23日 12:24:46 +0100 (Mo, 23 Feb 2009) | 2 lines
 
 #5349: C++ pure virtuals can also have an implementation.
........
 r69907 | georg.brandl | 2009年02月23日 19:33:48 +0100 (Mo, 23 Feb 2009) | 1 line
 
 Fix grammar.
........
 r69994 | georg.brandl | 2009年02月26日 18:36:26 +0100 (Do, 26 Feb 2009) | 1 line
 
 Document that setting sys.py3kwarning wont do anything.
........
 r70022 | georg.brandl | 2009年02月27日 17:23:18 +0100 (Fr, 27 Feb 2009) | 1 line
 
 #5361: fix typo.
........
 r70023 | georg.brandl | 2009年02月27日 17:39:26 +0100 (Fr, 27 Feb 2009) | 1 line
 
 #5363: fix cmpfiles() docs. Another instance where a prose description is twice as long as the code.
........
 r70025 | georg.brandl | 2009年02月27日 17:52:55 +0100 (Fr, 27 Feb 2009) | 1 line
 
 #5344: fix punctuation.
........
 r70026 | georg.brandl | 2009年02月27日 17:59:03 +0100 (Fr, 27 Feb 2009) | 1 line
 
 #5365: add quick look conversion table for different time representations.
........
 r70166 | georg.brandl | 2009年03月04日 19:24:41 +0100 (Mi, 04 Mär 2009) | 2 lines
 
 Remove obsolete stuff from string module docs.
........
 r70273 | georg.brandl | 2009年03月09日 15:25:07 +0100 (Mo, 09 Mär 2009) | 2 lines
 
 #5458: add a note when we started to raise RuntimeErrors.
........
 r70275 | georg.brandl | 2009年03月09日 17:35:48 +0100 (Mo, 09 Mär 2009) | 2 lines
 
 Add missing space.
........
 r70342 | georg.brandl | 2009年03月13日 20:03:58 +0100 (Fr, 13 Mär 2009) | 1 line
 
 #5486: typos.
........
 r70386 | georg.brandl | 2009年03月15日 22:32:06 +0100 (So, 15 Mär 2009) | 1 line
 
 #5496: fix docstring of lookup().
........
 r70387 | georg.brandl | 2009年03月15日 22:37:16 +0100 (So, 15 Mär 2009) | 1 line
 
 #5493: clarify __nonzero__ docs.
........
 r70389 | georg.brandl | 2009年03月15日 22:43:38 +0100 (So, 15 Mär 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日 22:44:43 +0100 (So, 15 Mär 2009) | 1 line
 
 #5491: clarify nested() semantics.
........
 r70392 | georg.brandl | 2009年03月15日 22:46:00 +0100 (So, 15 Mär 2009) | 1 line
 
 #5488: add missing struct member.
........
 r70393 | georg.brandl | 2009年03月15日 22:47:42 +0100 (So, 15 Mär 2009) | 1 line
 
 #5478: fix copy-paste oversight in function signature.
........
 r70395 | georg.brandl | 2009年03月15日 22:51:48 +0100 (So, 15 Mär 2009) | 1 line
 
 #5276: document IDLESTARTUP and .Idle.py.
........
 r70397 | georg.brandl | 2009年03月15日 22:53:56 +0100 (So, 15 Mär 2009) | 1 line
 
 #5469: add with statement to list of name-binding constructs.
........
 r70400 | georg.brandl | 2009年03月15日 22:59:37 +0100 (So, 15 Mär 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.
........
 r70418 | georg.brandl | 2009年03月16日 20:42:03 +0100 (Mo, 16 Mär 2009) | 1 line
 
 Add token markup.
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Doc/c-api/typeobj.rst
 python/branches/release26-maint/Doc/distutils/packageindex.rst
 python/branches/release26-maint/Doc/howto/regex.rst
 python/branches/release26-maint/Doc/library/2to3.rst
 python/branches/release26-maint/Doc/library/abc.rst
 python/branches/release26-maint/Doc/library/contextlib.rst
 python/branches/release26-maint/Doc/library/exceptions.rst
 python/branches/release26-maint/Doc/library/filecmp.rst
 python/branches/release26-maint/Doc/library/idle.rst
 python/branches/release26-maint/Doc/library/re.rst
 python/branches/release26-maint/Doc/library/stdtypes.rst
 python/branches/release26-maint/Doc/library/string.rst
 python/branches/release26-maint/Doc/library/sys.rst
 python/branches/release26-maint/Doc/library/threading.rst
 python/branches/release26-maint/Doc/library/time.rst
 python/branches/release26-maint/Doc/library/turtle.rst
 python/branches/release26-maint/Doc/library/xml.dom.rst
 python/branches/release26-maint/Doc/reference/datamodel.rst
 python/branches/release26-maint/Doc/reference/executionmodel.rst
 python/branches/release26-maint/Doc/whatsnew/2.6.rst
 python/branches/release26-maint/Lib/test/test_struct.py
 python/branches/release26-maint/Modules/_codecsmodule.c
 python/branches/release26-maint/Modules/_ctypes/_ctypes.c
 python/branches/release26-maint/Objects/typeobject.c
 python/branches/release26-maint/Objects/unicodeobject.c
Modified: python/branches/release26-maint/Doc/c-api/typeobj.rst
==============================================================================
--- python/branches/release26-maint/Doc/c-api/typeobj.rst	(original)
+++ python/branches/release26-maint/Doc/c-api/typeobj.rst	Sun Apr 5 23:48:06 2009
@@ -1180,6 +1180,7 @@
 binaryfunc nb_inplace_add;
 binaryfunc nb_inplace_subtract;
 binaryfunc nb_inplace_multiply;
+ binaryfunc nb_inplace_divide;
 binaryfunc nb_inplace_remainder;
 ternaryfunc nb_inplace_power;
 binaryfunc nb_inplace_lshift;
Modified: python/branches/release26-maint/Doc/distutils/packageindex.rst
==============================================================================
--- python/branches/release26-maint/Doc/distutils/packageindex.rst	(original)
+++ python/branches/release26-maint/Doc/distutils/packageindex.rst	Sun Apr 5 23:48:06 2009
@@ -91,4 +91,3 @@
 
 python setup.py register -r other
 
-
Modified: python/branches/release26-maint/Doc/howto/regex.rst
==============================================================================
--- python/branches/release26-maint/Doc/howto/regex.rst	(original)
+++ python/branches/release26-maint/Doc/howto/regex.rst	Sun Apr 5 23:48:06 2009
@@ -4,7 +4,7 @@
 Regular Expression HOWTO
 ****************************
 
-:Author: A.M. Kuchling
+:Author: A.M. Kuchling <amk at amk.ca>
 :Release: 0.05
 
 .. TODO:
Modified: python/branches/release26-maint/Doc/library/2to3.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/2to3.rst	(original)
+++ python/branches/release26-maint/Doc/library/2to3.rst	Sun Apr 5 23:48:06 2009
@@ -36,9 +36,9 @@
 $ 2to3 example.py
 
 A diff against the original source file is printed. 2to3 can also write the
-needed modifications right back to the source file. (Of course, a backup of the
-original is also be made unless :option:`-n` is also given.) Writing the
-changes back is enabled with the :option:`-w` flag::
+needed modifications right back to the source file. (A backup of the original
+file is made unless :option:`-n` is also given.) Writing the changes back is
+enabled with the :option:`-w` flag::
 
 $ 2to3 -w example.py
 
Modified: python/branches/release26-maint/Doc/library/abc.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/abc.rst	(original)
+++ python/branches/release26-maint/Doc/library/abc.rst	Sun Apr 5 23:48:06 2009
@@ -153,7 +153,7 @@
 
 .. note::
 
- Unlike C++'s pure virtual functions, or Java abstract methods, these abstract
+ Unlike Java abstract methods, these abstract
 methods may have an implementation. This implementation can be
 called via the :func:`super` mechanism from the class that
 overrides it. This could be useful as an end-point for a
Modified: python/branches/release26-maint/Doc/library/contextlib.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/contextlib.rst	(original)
+++ python/branches/release26-maint/Doc/library/contextlib.rst	Sun Apr 5 23:48:06 2009
@@ -63,14 +63,15 @@
 
 from contextlib import nested
 
- with nested(A, B, C) as (X, Y, Z):
+ with nested(A(), B(), C()) as (X, Y, Z):
 do_something()
 
 is equivalent to this::
 
- with A as X:
- with B as Y:
- with C as Z:
+ m1, m2, m3 = A(), B(), C()
+ with m1 as X:
+ with m2 as Y:
+ with m3 as Z:
 do_something()
 
 Note that if the :meth:`__exit__` method of one of the nested context managers
Modified: python/branches/release26-maint/Doc/library/exceptions.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/exceptions.rst	(original)
+++ python/branches/release26-maint/Doc/library/exceptions.rst	Sun Apr 5 23:48:06 2009
@@ -52,7 +52,7 @@
 The base class for all built-in exceptions. It is not meant to be directly
 inherited by user-defined classes (for that use :exc:`Exception`). If
 :func:`str` or :func:`unicode` is called on an instance of this class, the
- representation of the argument(s) to the instance are returned or the emptry
+ representation of the argument(s) to the instance are returned or the empty
 string when there were no arguments. All arguments are stored in :attr:`args`
 as a tuple.
 
Modified: python/branches/release26-maint/Doc/library/filecmp.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/filecmp.rst	(original)
+++ python/branches/release26-maint/Doc/library/filecmp.rst	Sun Apr 5 23:48:06 2009
@@ -31,17 +31,24 @@
 
 .. function:: cmpfiles(dir1, dir2, common[, shallow])
 
- Returns three lists of file names: *match*, *mismatch*, *errors*. *match*
- contains the list of files match in both directories, *mismatch* includes the
- names of those that don't, and *errros* lists the names of files which could not
- be compared. Files may be listed in *errors* because the user may lack
- permission to read them or many other reasons, but always that the comparison
- could not be done for some reason.
+ Compare the files in the two directories *dir1* and *dir2* whose names are
+ given by *common*.
 
- The *common* parameter is a list of file names found in both directories. The
- *shallow* parameter has the same meaning and default value as for
+ Returns three lists of file names: *match*, *mismatch*,
+ *errors*. *match* contains the list of files that match, *mismatch* contains
+ the names of those that don't, and *errors* lists the names of files which
+ could not be compared. Files are listed in *errors* if they don't exist in
+ one of the directories, the user lacks permission to read them or if the
+ comparison could not be done for some other reason.
+
+ The *shallow* parameter has the same meaning and default value as for
 :func:`filecmp.cmp`.
 
+ For example, ``cmpfiles('a', 'b', ['c', 'd/e'])`` will compare ``a/c`` with
+ ``b/c`` and ``a/d/e`` with ``b/d/e``. ``'c'`` and ``'d/e'`` will each be in
+ one of the three returned lists.
+
+
 Example::
 
 >>> import filecmp
Modified: python/branches/release26-maint/Doc/library/idle.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/idle.rst	(original)
+++ python/branches/release26-maint/Doc/library/idle.rst	Sun Apr 5 23:48:06 2009
@@ -253,6 +253,24 @@
 black
 
 
+Startup
+-------
+
+Upon startup with the ``-s`` option, IDLE will execute the file referenced by
+the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`.
+Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file
+referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for
+``PYTHONSTARTUP``. Files referenced by these environment variables are
+convenient places to store functions that are used frequently from the Idle
+shell, or for executing import statements to import common modules.
+
+In addition, ``Tk`` also loads a startup file if it is present. Note that the
+Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is
+looked for in the user's home directory. Statements in this file will be
+executed in the Tk namespace, so this file is not useful for importing functions
+to be used from Idle's Python shell.
+
+
 Command line usage
 ^^^^^^^^^^^^^^^^^^
 
Modified: python/branches/release26-maint/Doc/library/re.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/re.rst	(original)
+++ python/branches/release26-maint/Doc/library/re.rst	Sun Apr 5 23:48:06 2009
@@ -1093,7 +1093,7 @@
 string)`` or ``re.search(pattern, string)``.
 
 :func:`match` has an optional second parameter that gives an index in the string
-where the search is to start:
+where the search is to start::
 
 >>> pattern = re.compile("o")
 >>> pattern.match("dog") # No match as "o" is not at the start of "dog."
Modified: python/branches/release26-maint/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/stdtypes.rst	(original)
+++ python/branches/release26-maint/Doc/library/stdtypes.rst	Sun Apr 5 23:48:06 2009
@@ -1296,7 +1296,7 @@
 +------------+-----------------------------------------------------+-------+
 | ``'o'`` | Signed octal value. | \(1) |
 +------------+-----------------------------------------------------+-------+
-| ``'u'`` | Obselete type -- it is identical to ``'d'``. | \(7) |
+| ``'u'`` | Obsolete type -- it is identical to ``'d'``. | \(7) |
 +------------+-----------------------------------------------------+-------+
 | ``'x'`` | Signed hexadecimal (lowercase). | \(2) |
 +------------+-----------------------------------------------------+-------+
Modified: python/branches/release26-maint/Doc/library/string.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/string.rst	(original)
+++ python/branches/release26-maint/Doc/library/string.rst	Sun Apr 5 23:48:06 2009
@@ -62,10 +62,9 @@
 .. data:: lowercase
 
 A string containing all the characters that are considered lowercase letters.
- On most systems this is the string ``'abcdefghijklmnopqrstuvwxyz'``. Do not
- change its definition --- the effect on the routines :func:`upper` and
- :func:`swapcase` is undefined. The specific value is locale-dependent, and will
- be updated when :func:`locale.setlocale` is called.
+ On most systems this is the string ``'abcdefghijklmnopqrstuvwxyz'``. The
+ specific value is locale-dependent, and will be updated when
+ :func:`locale.setlocale` is called.
 
 
 .. data:: octdigits
@@ -89,18 +88,16 @@
 .. data:: uppercase
 
 A string containing all the characters that are considered uppercase letters.
- On most systems this is the string ``'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``. Do not
- change its definition --- the effect on the routines :func:`lower` and
- :func:`swapcase` is undefined. The specific value is locale-dependent, and will
- be updated when :func:`locale.setlocale` is called.
+ On most systems this is the string ``'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``. The
+ specific value is locale-dependent, and will be updated when
+ :func:`locale.setlocale` is called.
 
 
 .. data:: whitespace
 
 A string containing all characters that are considered whitespace. On most
 systems this includes the characters space, tab, linefeed, return, formfeed, and
- vertical tab. Do not change its definition --- the effect on the routines
- :func:`strip` and :func:`split` is undefined.
+ vertical tab.
 
 
 .. _new-string-formatting:
@@ -224,7 +221,7 @@
 
 .. productionlist:: sf
 replacement_field: "{" `field_name` ["!" `conversion`] [":" `format_spec`] "}"
- field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" element_index "]")*
+ field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" `element_index` "]")*
 attribute_name: `identifier`
 element_index: `integer`
 conversion: "r" | "s"
@@ -599,7 +596,7 @@
 
 Don't use strings derived from :const:`lowercase` and :const:`uppercase` as
 arguments; in some locales, these don't have the same length. For case
- conversions, always use :func:`lower` and :func:`upper`.
+ conversions, always use :meth:`str.lower` and :meth:`str.upper`.
 
 
 Deprecated string functions
Modified: python/branches/release26-maint/Doc/library/sys.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/sys.rst	(original)
+++ python/branches/release26-maint/Doc/library/sys.rst	Sun Apr 5 23:48:06 2009
@@ -661,7 +661,9 @@
 .. data:: py3kwarning
 
 Bool containing the status of the Python 3.0 warning flag. It's ``True``
- when Python is started with the -3 option.
+ when Python is started with the -3 option. (This should be considered
+ read-only; setting it to a different value doesn't have an effect on
+ Python 3.0 warnings.)
 
 .. versionadded:: 2.6
 
Modified: python/branches/release26-maint/Doc/library/threading.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/threading.rst	(original)
+++ python/branches/release26-maint/Doc/library/threading.rst	Sun Apr 5 23:48:06 2009
@@ -21,9 +21,14 @@
 deprecation of the ``camelCase`` names and they remain fully supported in
 both Python 2.x and 3.x.
 
-This module defines the following functions and objects:
+.. note::
+
+ Starting with Python 2.5, several Thread methods raise :exc:`RuntimeError`
+ instead of :exc:`AssertionError` if called erroneously.
 
 
+This module defines the following functions and objects:
+
 .. function:: active_count()
 activeCount()
 
Modified: python/branches/release26-maint/Doc/library/time.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/time.rst	(original)
+++ python/branches/release26-maint/Doc/library/time.rst	Sun Apr 5 23:48:06 2009
@@ -118,6 +118,24 @@
 The time value sequence was changed from a tuple to a :class:`struct_time`, with
 the addition of attribute names for the fields.
 
+* Use the following functions to convert between time representations:
+
+ +-------------------------+-------------------------+-------------------------+
+ | From | To | Use |
+ +=========================+=========================+=========================+
+ | seconds since the epoch | :class:`struct_time` in | :func:`gmtime` |
+ | | UTC | |
+ +-------------------------+-------------------------+-------------------------+
+ | seconds since the epoch | :class:`struct_time` in | :func:`localtime` |
+ | | local time | |
+ +-------------------------+-------------------------+-------------------------+
+ | :class:`struct_time` in | seconds since the epoch | :func:`calendar.timegm` |
+ | UTC | | |
+ +-------------------------+-------------------------+-------------------------+
+ | :class:`struct_time` in | seconds since the epoch | :func:`mktime` |
+ | local time | | |
+ +-------------------------+-------------------------+-------------------------+
+
 
 The module defines the following functions and data items:
 
Modified: python/branches/release26-maint/Doc/library/turtle.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/turtle.rst	(original)
+++ python/branches/release26-maint/Doc/library/turtle.rst	Sun Apr 5 23:48:06 2009
@@ -61,7 +61,7 @@
 
 The procedural interface provides functions which are derived from the methods
 of the classes :class:`Screen` and :class:`Turtle`. They have the same names as
-the corresponding methods. A screen object is automativally created whenever a
+the corresponding methods. A screen object is automatically created whenever a
 function derived from a Screen method is called. An (unnamed) turtle object is
 automatically created whenever any of the functions derived from a Turtle method
 is called.
@@ -1608,7 +1608,7 @@
 =========== ===========
 "polygon" a polygon-tuple, i.e. a tuple of pairs of coordinates
 "image" an image (in this form only used internally!)
- "compound" ``None`` (a compund shape has to be constructed using the
+ "compound" ``None`` (a compound shape has to be constructed using the
 :meth:`addcomponent` method)
 =========== ===========
 
@@ -1830,7 +1830,7 @@
 
 It contains:
 
-- a set of 15 demo scripts demonstrating differet features of the new module
+- a set of 15 demo scripts demonstrating different features of the new module
 :mod:`turtle`
 - a demo viewer :file:`turtleDemo.py` which can be used to view the sourcecode
 of the scripts and run them at the same time. 14 of the examples can be
Modified: python/branches/release26-maint/Doc/library/xml.dom.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/xml.dom.rst	(original)
+++ python/branches/release26-maint/Doc/library/xml.dom.rst	Sun Apr 5 23:48:06 2009
@@ -611,7 +611,7 @@
 Same as equivalent method in the :class:`Document` class.
 
 
-.. method:: Element.getElementsByTagNameNS(tagName)
+.. method:: Element.getElementsByTagNameNS(namespaceURI, localName)
 
 Same as equivalent method in the :class:`Document` class.
 
Modified: python/branches/release26-maint/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/release26-maint/Doc/reference/datamodel.rst	(original)
+++ python/branches/release26-maint/Doc/reference/datamodel.rst	Sun Apr 5 23:48:06 2009
@@ -1414,11 +1414,12 @@
 
 .. index:: single: __len__() (mapping object method)
 
- Called to implement truth value testing, and the built-in operation ``bool()``;
+ Called to implement truth value testing and the built-in operation ``bool()``;
 should return ``False`` or ``True``, or their integer equivalents ``0`` or
- ``1``. When this method is not defined, :meth:`__len__` is called, if it is
- defined (see below). If a class defines neither :meth:`__len__` nor
- :meth:`__nonzero__`, all its instances are considered true.
+ ``1``. When this method is not defined, :meth:`__len__` is called, if it is
+ defined, and the object is considered true if its result is nonzero.
+ If a class defines neither :meth:`__len__` nor :meth:`__nonzero__`, all its
+ instances are considered true.
 
 
 .. method:: object.__unicode__(self)
Modified: python/branches/release26-maint/Doc/reference/executionmodel.rst
==============================================================================
--- python/branches/release26-maint/Doc/reference/executionmodel.rst	(original)
+++ python/branches/release26-maint/Doc/reference/executionmodel.rst	Sun Apr 5 23:48:06 2009
@@ -87,9 +87,10 @@
 The following constructs bind names: formal parameters to functions,
 :keyword:`import` statements, class and function definitions (these bind the
 class or function name in the defining block), and targets that are identifiers
-if occurring in an assignment, :keyword:`for` loop header, or in the second
-position of an :keyword:`except` clause header. The :keyword:`import` statement
-of the form "``from ...import *``" binds all names defined in the imported
+if occurring in an assignment, :keyword:`for` loop header, in the second
+position of an :keyword:`except` clause header or after :keyword:`as` in a
+:keyword:`with` statement. The :keyword:`import` statement
+of the form ``from ... import *`` binds all names defined in the imported
 module, except those beginning with an underscore. This form may only be used
 at the module level.
 
Modified: python/branches/release26-maint/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/release26-maint/Doc/whatsnew/2.6.rst	(original)
+++ python/branches/release26-maint/Doc/whatsnew/2.6.rst	Sun Apr 5 23:48:06 2009
@@ -270,7 +270,7 @@
 
 The expression is evaluated, and it should result in an object that supports the
 context management protocol (that is, has :meth:`__enter__` and :meth:`__exit__`
-methods.
+methods).
 
 The object's :meth:`__enter__` is called before *with-block* is executed and
 therefore can run set-up code. It also may return a value that is bound to the
Modified: python/branches/release26-maint/Lib/test/test_struct.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_struct.py	(original)
+++ python/branches/release26-maint/Lib/test/test_struct.py	Sun Apr 5 23:48:06 2009
@@ -512,6 +512,10 @@
 self.assertRaises(struct.error, s.pack_into, small_buf, 0, test_string)
 self.assertRaises(struct.error, s.pack_into, small_buf, 2, test_string)
 
+ # Test bogus offset (issue 3694)
+ sb = small_buf
+ self.assertRaises(TypeError, struct.pack_into, b'1', sb, None)
+
 def test_pack_into_fn(self):
 test_string = 'Reykjavik rocks, eow!'
 writable_buf = array.array('c', ' '*100)
Modified: python/branches/release26-maint/Modules/_codecsmodule.c
==============================================================================
--- python/branches/release26-maint/Modules/_codecsmodule.c	(original)
+++ python/branches/release26-maint/Modules/_codecsmodule.c	Sun Apr 5 23:48:06 2009
@@ -61,7 +61,7 @@
 "lookup(encoding) -> CodecInfo\n\
 \n\
 Looks up a codec tuple in the Python codec registry and returns\n\
-a tuple of function (or a CodecInfo object).");
+a CodecInfo object.");
 
 static
 PyObject *codec_lookup(PyObject *self, PyObject *args)
Modified: python/branches/release26-maint/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/release26-maint/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/release26-maint/Modules/_ctypes/_ctypes.c	Sun Apr 5 23:48:06 2009
@@ -599,13 +599,14 @@
 #else
 	address = (void *)ctypes_dlsym(handle, name);
 	if (!address) {
-		PyErr_Format(PyExc_ValueError,
 #ifdef __CYGWIN__
 /* dlerror() isn't very helpful on cygwin */
+		PyErr_Format(PyExc_ValueError,
 			 "symbol '%s' not found (%s) ",
-			 name,
+			 name);
+#else
+		PyErr_SetString(PyExc_ValueError, ctypes_dlerror());
 #endif
-			 ctypes_dlerror());
 		return NULL;
 	}
 #endif
@@ -3283,13 +3284,14 @@
 #else
 	address = (PPROC)ctypes_dlsym(handle, name);
 	if (!address) {
-		PyErr_Format(PyExc_AttributeError,
 #ifdef __CYGWIN__
 /* dlerror() isn't very helpful on cygwin */
+		PyErr_Format(PyExc_AttributeError,
 			 "function '%s' not found (%s) ",
-			 name,
+			 name);
+#else
+		PyErr_SetString(PyExc_AttributeError, ctypes_dlerror());
 #endif
-			 ctypes_dlerror());
 		return NULL;
 	}
 #endif
Modified: python/branches/release26-maint/Objects/typeobject.c
==============================================================================
--- python/branches/release26-maint/Objects/typeobject.c	(original)
+++ python/branches/release26-maint/Objects/typeobject.c	Sun Apr 5 23:48:06 2009
@@ -5092,6 +5092,7 @@
 	PyObject *func, *args;
 	static PyObject *nonzero_str, *len_str;
 	int result = -1;
+	int using_len = 0;
 
 	func = lookup_maybe(self, "__nonzero__", &nonzero_str);
 	if (func == NULL) {
@@ -5100,6 +5101,7 @@
 		func = lookup_maybe(self, "__len__", &len_str);
 		if (func == NULL)
 			return PyErr_Occurred() ? -1 : 1;
+		using_len = 1;
 	}
 	args = PyTuple_New(0);
 	if (args != NULL) {
@@ -5110,8 +5112,10 @@
 				result = PyObject_IsTrue(temp);
 			else {
 				PyErr_Format(PyExc_TypeError,
-					 "__nonzero__ should return "
+					 "%s should return "
 					 "bool or int, returned %s",
+					 (using_len ? "__len__"
+					 : "__nonzero__"),
 					 temp->ob_type->tp_name);
 				result = -1;
 			}
Modified: python/branches/release26-maint/Objects/unicodeobject.c
==============================================================================
--- python/branches/release26-maint/Objects/unicodeobject.c	(original)
+++ python/branches/release26-maint/Objects/unicodeobject.c	Sun Apr 5 23:48:06 2009
@@ -1385,7 +1385,7 @@
 if (restuple == NULL)
 goto onError;
 if (!PyTuple_Check(restuple)) {
- PyErr_Format(PyExc_TypeError, &argparse[4]);
+ PyErr_SetString(PyExc_TypeError, &argparse[4]);
 goto onError;
 }
 if (!PyArg_ParseTuple(restuple, argparse, &PyUnicode_Type, &repunicode, &newpos))
@@ -3440,7 +3440,7 @@
 if (restuple == NULL)
 return NULL;
 if (!PyTuple_Check(restuple)) {
- PyErr_Format(PyExc_TypeError, &argparse[4]);
+ PyErr_SetString(PyExc_TypeError, &argparse[4]);
 Py_DECREF(restuple);
 return NULL;
 }
@@ -4712,7 +4712,7 @@
 if (restuple == NULL)
 return NULL;
 if (!PyTuple_Check(restuple)) {
- PyErr_Format(PyExc_TypeError, &argparse[4]);
+ PyErr_SetString(PyExc_TypeError, &argparse[4]);
 Py_DECREF(restuple);
 return NULL;
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /