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.
........
This commit is contained in:
Christian Heimes 2008-01-09 00:17:24 +00:00
parent 790c823201
commit 2380ac740e
18 changed files with 436 additions and 72 deletions

View file

@ -131,6 +131,16 @@ This module offers the following functions:
+-------+--------------------------------------------+
.. 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, and also disconnect the Windows handle from the handle object.
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

View file

@ -397,8 +397,8 @@ they add the ability to access fields by name instead of position index.
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 @@ by the :mod:`csv` or :mod:`sqlite3` modules::
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 @@ three additional methods and one attribute.
.. 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 @@ function::
>>> 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 @@ a fixed-width print format::
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')

View file

@ -177,8 +177,13 @@ XMLParser Objects
.. 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