Merged revisions 59843-59863 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59844 | raymond.hettinger | 2008-01-07 21:56:05 +0100 (Mon, 07 Jan 2008) | 1 line
Use get() instead of pop() for the optimized version of _replace().
........
r59847 | raymond.hettinger | 2008-01-07 22:33:51 +0100 (Mon, 07 Jan 2008) | 1 line
Documentation nits.
........
r59849 | raymond.hettinger | 2008-01-08 03:02:05 +0100 (Tue, 08 Jan 2008) | 1 line
Expand comment.
........
r59850 | raymond.hettinger | 2008-01-08 03:24:15 +0100 (Tue, 08 Jan 2008) | 1 line
Docs on named tuple's naming conventions and limits of subclassing
........
r59851 | christian.heimes | 2008-01-08 04:40:04 +0100 (Tue, 08 Jan 2008) | 1 line
It's verbose, not debug
........
r59852 | facundo.batista | 2008-01-08 13:25:20 +0100 (Tue, 08 Jan 2008) | 4 lines
Issue #1757: The hash of a Decimal instance is no longer affected
by the current context. Thanks Mark Dickinson.
........
r59853 | andrew.kuchling | 2008-01-08 15:30:55 +0100 (Tue, 08 Jan 2008) | 1 line
Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects
........
r59854 | andrew.kuchling | 2008-01-08 15:56:02 +0100 (Tue, 08 Jan 2008) | 1 line
Patch 1114: fix compilation of curses module on 64-bit AIX, and any other LP64 platforms where attr_t isn't a C long
........
r59856 | thomas.heller | 2008-01-08 16:15:09 +0100 (Tue, 08 Jan 2008) | 5 lines
Use relative instead of absolute filenames in the C-level tracebacks.
This prevents traceback prints pointing to files in this way:
File "\loewis\25\python\Modules\_ctypes\callbacks.c", line 206, in 'calling callback function'
........
r59857 | christian.heimes | 2008-01-08 16:46:10 +0100 (Tue, 08 Jan 2008) | 2 lines
Added __enter__ and __exit__ functions to HKEY object
Added ExpandEnvironmentStrings to the _winreg module.
........
r59858 | georg.brandl | 2008-01-08 17:18:26 +0100 (Tue, 08 Jan 2008) | 2 lines
Fix markup errors from r59857 and clarify key.__enter__/__exit__ docs
........
r59860 | georg.brandl | 2008-01-08 20:42:30 +0100 (Tue, 08 Jan 2008) | 2 lines
Better method for associating .py files with the interpreter.
........
r59862 | facundo.batista | 2008-01-08 22:10:12 +0100 (Tue, 08 Jan 2008) | 9 lines
Issue 846388. Adds a call to PyErr_CheckSignals to
SRE_MATCH so that signal handlers can be invoked during
long regular expression matches. It also adds a new
error return value indicating that an exception
occurred in a signal handler during the match, allowing
exceptions in the signal handler to propagate up to the
main loop. Thanks Josh Hoyt and Ralf Schmitt.
........
diff --git a/Doc/library/_winreg.rst b/Doc/library/_winreg.rst
index a3fe72b..7ce34b4 100644
--- a/Doc/library/_winreg.rst
+++ b/Doc/library/_winreg.rst
@@ -131,6 +131,16 @@
+-------+--------------------------------------------+
+.. function:: ExpandEnvironmentStrings(unicode)
+
+ Expands environment strings %NAME% in unicode string like const:`REG_EXPAND_SZ`::
+
+ >>> ExpandEnvironmentStrings(u"%windir%")
+ u"C:\\Windows"
+
+ .. versionadded:: 2.6
+
+
.. function:: FlushKey(key)
Writes all the attributes of a key to the registry.
@@ -416,3 +426,16 @@
handle is not closed. You would call this function when you need the
underlying Win32 handle to exist beyond the lifetime of the handle object.
+.. method:: PyHKEY.__enter__()
+ PyHKEY.__exit__(\*exc_info)
+
+ The HKEY object implements :meth:`__enter__` and :meth:`__exit__` and thus
+ supports the context protocol for the :keyword:`with` statement::
+
+ with OpenKey(HKEY_LOCAL_MACHINE, "foo") as key:
+ # ... work with key ...
+
+ will automatically close *key* when control leaves the :keyword:`with` block.
+
+ .. versionadded:: 2.6
+
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 2b8e279..0c440d6 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -397,8 +397,8 @@
method which lists the tuple contents in a ``name=value`` format.
The *fieldnames* are a single string with each fieldname separated by whitespace
- and/or commas (for example 'x y' or 'x, y'). Alternatively, the *fieldnames*
- can be specified with a sequence of strings (such as ['x', 'y']).
+ and/or commas (for example 'x y' or 'x, y'). Alternatively, *fieldnames*
+ can be a sequence of strings (such as ['x', 'y']).
Any valid Python identifier may be used for a fieldname except for names
starting with an underscore. Valid identifiers consist of letters, digits,
@@ -477,7 +477,8 @@
print emp.name, emp.title
In addition to the methods inherited from tuples, named tuples support
-three additional methods and one attribute.
+three additional methods and one attribute. To prevent conflicts with
+field names, the method and attribute names start with an underscore.
.. method:: somenamedtuple._make(iterable)
@@ -513,7 +514,7 @@
.. attribute:: somenamedtuple._fields
- Tuple of strings listing the field names. This is useful for introspection
+ Tuple of strings listing the field names. Useful for introspection
and for creating new named tuple types from existing named tuples.
::
@@ -532,7 +533,7 @@
>>> getattr(p, 'x')
11
-When casting a dictionary to a named tuple, use the double-star-operator [#]_::
+To cast a dictionary to a named tuple, use the double-star-operator [#]_::
>>> d = {'x': 11, 'y': 22}
>>> Point(**d)
@@ -557,14 +558,20 @@
Point: x= 1.286 y= 6.000 hypot= 6.136
Another use for subclassing is to replace performance critcal methods with
-faster versions that bypass error-checking and localize variable access::
+faster versions that bypass error-checking and that localize variable access::
>>> class Point(namedtuple('Point', 'x y')):
_make = classmethod(tuple.__new__)
def _replace(self, _map=map, **kwds):
- return self._make(_map(kwds.pop, ('x', 'y'), self))
+ return self._make(_map(kwds.get, ('x', 'y'), self))
-Default values can be implemented by using :meth:`_replace`:: to
+
+Subclassing is not useful for adding new, stored fields. Instead, simply
+create a new named tuple type from the :attr:`_fields` attribute::
+
+ >>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
+
+Default values can be implemented by using :meth:`_replace` to
customize a prototype instance::
>>> Account = namedtuple('Account', 'owner balance transaction_count')
diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst
index 29ca540..3a3305c 100644
--- a/Doc/library/pyexpat.rst
+++ b/Doc/library/pyexpat.rst
@@ -177,8 +177,13 @@
.. attribute:: xmlparser.buffer_size
- The size of the buffer used when :attr:`buffer_text` is true. This value cannot
- be changed at this time.
+ The size of the buffer used when :attr:`buffer_text` is true.
+ A new buffer size can be set by assigning a new integer value
+ to this attribute.
+ When the size is changed, the buffer will be flushed.
+
+ .. versionchanged:: 2.6
+ The buffer size can now be changed.
.. attribute:: xmlparser.buffer_text
diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst
index 2b52544..1753b6d 100644
--- a/Doc/using/windows.rst
+++ b/Doc/using/windows.rst
@@ -188,16 +188,17 @@
startup.
You can also make all ``.py`` scripts execute with :program:`pythonw.exe`,
-setting this through the usual facilites, for example (names might differ,
-depending on your version of Windows):
+setting this through the usual facilites, for example (might require
+administrative rights):
-#. Open the context menu of a :file:`{*}.py` file.
-#. Click :menuselection:`Open with...`.
-#. Choose the interpreter of your choice (utilize :guilabel:`Other...` or
- :guilabel:`Choose Program...` if it is not in the list of default programs).
-#. Check :guilabel:`Always open files with this program`.
-#. Click :guilabel:`OK`.
+#. Launch a command prompt.
+#. Associate the correct file group with ``.py`` scripts::
+
+ assoc .py=Python.File
+#. Redirect all Python files to the new executable::
+
+ ftype Python.File=C:\Path\to\pythonw.exe "%1" %*
Additional modules
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst
index fee298d..4d90d35 100644
--- a/Doc/whatsnew/2.6.rst
+++ b/Doc/whatsnew/2.6.rst
@@ -875,6 +875,13 @@
changed and :const:`UF_APPEND` to indicate that data can only be appended to the
file. (Contributed by M. Levinson.)
+* The :mod:`pyexpat` module's :class:`Parser` objects now allow setting
+ their :attr:`buffer_size` attribute to change the size of the buffer
+ used to hold character data.
+ (Contributed by Achim Gaedke.)
+
+ .. Patch 1137
+
* The :mod:`random` module's :class:`Random` objects can
now be pickled on a 32-bit system and unpickled on a 64-bit
system, and vice versa. Unfortunately, this change also means