summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew/2.6.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/whatsnew/2.6.rst')
-rw-r--r--Doc/whatsnew/2.6.rst214
1 files changed, 192 insertions, 22 deletions
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst
index 2dc5844..4d52716 100644
--- a/Doc/whatsnew/2.6.rst
+++ b/Doc/whatsnew/2.6.rst
@@ -67,7 +67,6 @@ new feature.
.. % Large, PEP-level features and changes should be described here.
.. % Should there be a new section here for 3k migration?
.. % Or perhaps a more general section describing module changes/deprecation?
-.. % sets module deprecated
.. % ======================================================================
Python 3.0
@@ -75,7 +74,23 @@ Python 3.0
.. % XXX add general comment about Python 3.0 features in 2.6
-.. % XXX mention -3 switch
+The development cycle for Python 2.6 also saw the release of the first
+alphas of Python 3.0, and the development of 3.0 has influenced
+a number of features in 2.6.
+
+Python 3.0 is a far-ranging redesign of Python that breaks
+compatibility with the 2.x series. This means that existing Python
+code will need a certain amount of conversion in order to run on
+Python 3.0. However, not all the changes in 3.0 necessarily break
+compatibility. In cases where new features won't cause existing code
+to break, they've been backported to 2.6 and are described in this
+document in the appropriate place. Some of the 3.0-derived features
+are:
+
+* A :meth:`__complex__` method for converting objects to a complex number.
+* Alternate syntax for catching exceptions: ``except TypeError as exc``.
+* The addition of :func:`functools.reduce` as a synonym for the built-in
+ :func:`reduce` function.
A new command-line switch, :option:`-3`, enables warnings
about features that will be removed in Python 3.0. You can run code
@@ -406,11 +421,6 @@ Other Language Changes
Here are all of the changes that Python 2.6 makes to the core Python language.
-* Changes to the :class:`Exception` interface
- as dictated by :pep:`352` continue to be made. For 2.6,
- the :attr:`message` attribute is being deprecated in favor of the
- :attr:`args` attribute.
-
* When calling a function using the ``**`` syntax to provide keyword
arguments, you are no longer required to use a Python dictionary;
any mapping will now work::
@@ -426,8 +436,29 @@ Here are all of the changes that Python 2.6 makes to the core Python language.
.. % Patch 1686487
+* The built-in types now have improved support for extended slicing syntax,
+ where various combinations of ``(start, stop, step)`` are supplied.
+ Previously, the support was partial and certain corner cases wouldn't work.
+ (Implemented by Thomas Wouters.)
+
+ .. % Revision 57619
+
+* C functions and methods that use
+ :cfunc:`PyComplex_AsCComplex` will now accept arguments that
+ have a :meth:`__complex__` method. In particular, the functions in the
+ :mod:`cmath` module will now accept objects with this method.
+ This is a backport of a Python 3.0 change.
+ (Contributed by Mark Dickinson.)
+
+ .. % Patch #1675423
+
+* Changes to the :class:`Exception` interface
+ as dictated by :pep:`352` continue to be made. For 2.6,
+ the :attr:`message` attribute is being deprecated in favor of the
+ :attr:`args` attribute.
+
* The :func:`compile` built-in function now accepts keyword arguments
- as well as positional parameters. (Contributed by XXX.)
+ as well as positional parameters. (Contributed by Thomas Wouters.)
.. % Patch 1444529
@@ -483,21 +514,73 @@ fixes. Here's a partial list of the most notable changes, sorted alphabetically
by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
complete list of changes, or look through the CVS logs for all the details.
-* A new data type in the :mod:`collections` module: :class:`NamedTuple(typename,
+* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
+ available, instead of restricting itself to protocol 1.
+ (Contributed by W. Barnes.)
+
+ .. % Patch 1551443
+
+* A new data type in the :mod:`collections` module: :class:`namedtuple(typename,
fieldnames)` is a factory function that creates subclasses of the standard tuple
whose fields are accessible by name as well as index. For example::
- var_type = collections.NamedTuple('variable',
- 'id name type size')
- var = var_type(1, 'frequency', 'int', 4)
+ >>> var_type = collections.namedtuple('variable',
+ ... 'id name type size')
+ # Names are separated by spaces or commas.
+ # 'id, name, type, size' would also work.
+ >>> var_type.__fields__
+ ('id', 'name', 'type', 'size')
+
+ >>> var = var_type(1, 'frequency', 'int', 4)
+ >>> print var[0], var.id # Equivalent
+ 1 1
+ >>> print var[2], var.type # Equivalent
+ int int
+ >>> var.__asdict__()
+ {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'}
+ >>> v2 = var.__replace__('name', 'amplitude')
+ >>> v2
+ variable(id=1, name='amplitude', type='int', size=4)
- print var[0], var.id # Equivalent
- print var[2], var.type # Equivalent
+ (Contributed by Raymond Hettinger.)
+
+* Another change to the :mod:`collections` module is that the
+ :class:`deque` type now supports an optional `maxlen` parameter;
+ if supplied, the deque's size will be restricted to no more
+ than ``maxlen`` items. Adding more items to a full deque causes
+ old items to be discarded.
+
+ ::
+
+ >>> from collections import deque
+ >>> dq=deque(maxlen=3)
+ >>> dq
+ deque([], maxlen=3)
+ >>> dq.append(1) ; dq.append(2) ; dq.append(3)
+ >>> dq
+ deque([1, 2, 3], maxlen=3)
+ >>> dq.append(4)
+ >>> dq
+ deque([2, 3, 4], maxlen=3)
(Contributed by Raymond Hettinger.)
+* The :mod:`ctypes` module now supports a :class:`c_bool` datatype
+ that represents the C99 ``bool`` type. (Contributed by David Remahl.)
+
+ .. % Patch 1649190
+
+ The :mod:`ctypes` string, buffer and array types also have improved
+ support for extended slicing syntax,
+ where various combinations of ``(start, stop, step)`` are supplied.
+ (Implemented by Thomas Wouters.)
+
+ .. % Revision 57769
+
+
* A new method in the :mod:`curses` module: for a window, :meth:`chgat` changes
- the display characters for a certain number of characters on a single line. ::
+ the display characters for a certain number of characters on a single line.
+ ::
# Boldface text starting at y=0,x=21
# and affecting the rest of the line.
@@ -505,11 +588,33 @@ complete list of changes, or look through the CVS logs for all the details.
(Contributed by Fabian Kreutz.)
+* The :mod:`decimal` module was updated to version 1.66 of
+ `the General Decimal Specification <http://www2.hursley.ibm.com/decimal/decarith.html>`__. New features
+ include some methods for some basic mathematical functions such as
+ :meth:`exp` and :meth:`log10`::
+
+ >>> Decimal(1).exp()
+ Decimal("2.718281828459045235360287471")
+ >>> Decimal("2.7182818").ln()
+ Decimal("0.9999999895305022877376682436")
+ >>> Decimal(1000).log10()
+ Decimal("3")
+
+ (Implemented by Facundo Batista and Mark Dickinson.)
+
* An optional ``timeout`` parameter was added to the
:class:`ftplib.FTP` class constructor as well as the :meth:`connect`
method, specifying a timeout measured in seconds. (Added by Facundo
Batista.)
+* The :func:`reduce` built-in function is also available in the
+ :mod:`functools` module. In Python 3.0, the built-in is dropped and it's
+ only available from :mod:`functools`; currently there are no plans
+ to drop the built-in in the 2.x series. (Patched by
+ Christian Heimes.)
+
+ .. % Patch 1739906
+
* The :func:`glob.glob` function can now return Unicode filenames if
a Unicode path was used and Unicode filenames are matched within the directory.
@@ -548,7 +653,7 @@ complete list of changes, or look through the CVS logs for all the details.
.. % Patch #1490190
-* The :func:`os.walk` function now has a "followlinks" parameter. If
+* The :func:`os.walk` function now has a ``followlinks`` parameter. If
set to True, it will follow symlinks pointing to directories and
visit the directory's contents. For backward compatibility, the
parameter's default value is false. Note that the function can fall
@@ -557,6 +662,12 @@ complete list of changes, or look through the CVS logs for all the details.
.. % Patch 1273829
+* The ``os.environ`` object's :meth:`clear` method will now unset the
+ environment variables using :func:`os.unsetenv` in addition to clearing
+ the object's keys. (Contributed by Martin Horcicka.)
+
+ .. % Patch #1181
+
* In the :mod:`os.path` module, the :func:`splitext` function
has been changed to not split on leading period characters.
This produces better results when operating on Unix's dot-files.
@@ -574,10 +685,17 @@ complete list of changes, or look through the CVS logs for all the details.
On Windows, :func:`os.path.expandvars` will now expand environment variables
in the form "%var%", and "~user" will be expanded into the
- user's home directory path. (Contributed by XXX.)
+ user's home directory path. (Contributed by Josiah Carlson.)
.. % Patch 957650
+* The Python debugger provided by the :mod:`pdb` module
+ gained a new command: "run" restarts the Python program being debugged,
+ and can optionally take new command-line arguments for the program.
+ (Contributed by Rocky Bernstein.)
+
+ .. % Patch #1393667
+
* New functions in the :mod:`posix` module: :func:`chflags` and :func:`lchflags`
are wrappers for the corresponding system calls (where they're available).
Constants for the flag values are defined in the :mod:`stat` module; some
@@ -587,6 +705,9 @@ complete list of changes, or look through the CVS logs for all the details.
* The :mod:`rgbimg` module has been removed.
+* The :mod:`sets` module has been deprecated; it's better to
+ use the built-in :class:`set` and :class:`frozenset` types.
+
* The :mod:`smtplib` module now supports SMTP over SSL thanks to the
addition of the :class:`SMTP_SSL` class. This class supports an
interface identical to the existing :class:`SMTP` class. Both
@@ -701,8 +822,47 @@ complete list of changes, or look through the CVS logs for all the details.
(Added by Facundo Batista.)
+* The XML-RPC classes :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
+ classes can now be prevented from immediately opening and binding to
+ their socket by passing True as the ``bind_and_activate``
+ constructor parameter. This can be used to modify the instance's
+ :attr:`allow_reuse_address` attribute before calling the
+ :meth:`server_bind` and :meth:`server_activate` methods to
+ open the socket and begin listening for connections.
+ (Contributed by Peter Parente.)
+
+ .. % Patch 1599845
+
+ :class:`SimpleXMLRPCServer` also has a :attr:`_send_traceback_header`
+ attribute; if true, the exception and formatted traceback are returned
+ as HTTP headers "X-Exception" and "X-Traceback". This feature is
+ for debugging purposes only and should not be used on production servers
+ because the tracebacks could possibly reveal passwords or other sensitive
+ information. (Contributed by Alan McIntyre as part of his
+ project for Google's Summer of Code 2007.)
+
.. % ======================================================================
-.. % whole new modules get described in \subsections here
+.. % whole new modules get described in subsections here
+
+Improved SSL Support
+--------------------------------------------------
+
+Bill Janssen made extensive improvements to Python 2.6's support for
+SSL.
+
+XXX use ssl.sslsocket - subclass of socket.socket.
+
+XXX Can specify if certificate is required, and obtain certificate info
+by calling getpeercert method.
+
+XXX sslwrap() behaves like socket.ssl
+
+XXX Certain features require the OpenSSL package to be installed, notably
+ the 'openssl' binary.
+
+.. seealso::
+
+ SSL module documentation.
.. % ======================================================================
@@ -712,7 +872,13 @@ Build and C API Changes
Changes to Python's build process and to the C API include:
-* Detailed changes are listed here.
+* The BerkeleyDB module now has a C API object, available as
+ ``bsddb.db.api``. This object can be used by other C extensions
+ that wish to use the :mod:`bsddb` module for their own purposes.
+ (Contributed by Duncan Grisby.)
+
+ .. % Patch 1551895
+
.. % ======================================================================
@@ -737,7 +903,7 @@ are likely to be underestimates.
Some of the more notable changes are:
-* Details go here.
+* Details will go here.
.. % ======================================================================
@@ -748,8 +914,12 @@ Porting to Python 2.6
This section lists previously described changes that may require changes to your
code:
-* The :mod:`socket` module exception :exc:`socket.error` now inherits from
- :exc:`IOError`.
+* The :mod:`socket` module exception :exc:`socket.error` now inherits
+ from :exc:`IOError`. Previously it wasn't a subclass of
+ :exc:`StandardError` but now it is, through :exc:`IOError`.
+ (Implemented by Gregory P. Smith.)
+
+ .. % http://bugs.python.org/issue1706815
.. % ======================================================================