Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9eea480

Browse files
committed
Merged revisions 76852,77001,77115,77127 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r76852 | benjamin.peterson | 2009-12-15 21:36:22 -0600 (Tue, 15 Dec 2009) | 1 line remove type_compare, since type_richcompare does the same trick ........ r77001 | brett.cannon | 2009-12-21 20:37:37 -0600 (Mon, 21 Dec 2009) | 1 line Make a word plural. ........ r77115 | andrew.kuchling | 2009-12-29 14:10:16 -0600 (Tue, 29 Dec 2009) | 1 line Various additions ........ r77127 | andrew.kuchling | 2009-12-29 17:41:04 -0600 (Tue, 29 Dec 2009) | 1 line Add various items ........
1 parent b2d9046 commit 9eea480

1 file changed

Lines changed: 132 additions & 27 deletions

File tree

Doc/whatsnew/2.7.rst

Lines changed: 132 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
This saves the maintainer some effort going through the SVN logs
5050
when researching a change.
5151
52-
This article explains the new features in Python 2.7. No release
53-
schedule has been decided yet for 2.7; the schedule will eventually be
54-
described in :pep:`373`.
52+
This article explains the new features in Python 2.7. The final
53+
release of 2.7 is currently scheduled for June 2010; the detailed
54+
schedule is described in :pep:`373`.
5555

5656
.. Compare with previous release in 2 - 3 sentences here.
5757
add hyperlink when the documentation becomes available online.
@@ -73,6 +73,11 @@ A partial list of 3.1 features that were backported to 2.7:
7373
* The new format specifier described in :ref:`pep-0378`.
7474
* The :class:`memoryview` object.
7575
* A small subset of the :mod:`importlib` module `described below <#importlib-section>`__.
76+
* Float-to-string and string-to-float conversions now round their
77+
results more correctly. And :func:`repr` of a floating-point
78+
number *x* returns a result that's guaranteed to round back to the
79+
same number when converted back to a string.
80+
* The :cfunc:`PyLong_AsLongAndOverflow` C API function.
7681

7782
One porting change: the :option:`-3` switch now automatically
7883
enables the :option:`-Qwarn` switch that causes warnings
@@ -237,6 +242,33 @@ Some smaller changes made to the core Python language are:
237242
(Proposed in http://codereview.appspot.com/53094; implemented by
238243
Georg Brandl.)
239244

245+
* Conversions between floating-point numbers and strings are
246+
now correctly rounded on most platforms. These conversions occur
247+
in many different places: :func:`str` on
248+
floats and complex numbers; the :class:`float` and :class:`complex`
249+
constructors;
250+
numeric formatting; serialization and
251+
deserialization of floats and complex numbers using the
252+
:mod:`marshal`, :mod:`pickle`
253+
and :mod:`json` modules;
254+
parsing of float and imaginary literals in Python code;
255+
and :class:`Decimal`-to-float conversion.
256+
257+
Related to this, the :func:`repr` of a floating-point number *x*
258+
now returns a result based on the shortest decimal string that's
259+
guaranteed to round back to *x* under correct rounding (with
260+
round-half-to-even rounding mode). Previously it gave a string
261+
based on rounding x to 17 decimal digits.
262+
263+
The rounding library responsible for this improvement works on
264+
Windows, and on Unix platforms using the gcc, icc, or suncc
265+
compilers. There may be a small number of platforms where correct
266+
operation of this code cannot be guaranteed, so the code is not
267+
used on such systems.
268+
269+
Implemented by Mark Dickinson, using David Gay's :file:`dtoa.c` library;
270+
:issue:`7117`.
271+
240272
* The :meth:`str.format` method now supports automatic numbering of the replacement
241273
fields. This makes using :meth:`str.format` more closely resemble using
242274
``%s`` formatting::
@@ -259,6 +291,10 @@ Some smaller changes made to the core Python language are:
259291
alignment is applied to the whole of the resulting ``1.5+3j``
260292
output. (Contributed by Eric Smith; :issue:`1588`.)
261293

294+
The 'F' format code now always formats its output using uppercase characters,
295+
so it will now produce 'INF' and 'NAN'.
296+
(Contributed by Eric Smith; :issue:`3382`.)
297+
262298
* The :func:`int` and :func:`long` types gained a ``bit_length``
263299
method that returns the number of bits necessary to represent
264300
its argument in binary::
@@ -301,6 +337,9 @@ Some smaller changes made to the core Python language are:
301337

302338
(Implemented by Mark Dickinson; :issue:`3166`.)
303339

340+
Integer division is also more accurate in its rounding behaviours. (Also
341+
implemented by Mark Dickinson; :issue:`1811`.)
342+
304343
* The :class:`bytearray` type's :meth:`translate` method now accepts
305344
``None`` as its first argument. (Fixed by Georg Brandl;
306345
:issue:`4759`.)
@@ -315,6 +354,15 @@ Some smaller changes made to the core Python language are:
315354
supported. (Contributed by Alexander Belchenko and Amaury Forgeot
316355
d'Arc; :issue:`1616979`.)
317356

357+
* The :class:`file` object will now set the :attr:`filename` attribute
358+
on the :exc:`IOError` exception when trying to open a directory
359+
on POSIX platforms. (Noted by Jan Kaliszewski; :issue:`4764`.)
360+
361+
* Extra parentheses in function definitions are illegal in Python 3.x,
362+
meaning that you get a syntax error from ``def f((x)): pass``. In
363+
Python3-warning mode, Python 2.7 will now warn about this odd usage.
364+
(Noted by James Lingard; :issue:`7362`.)
365+
318366
.. ======================================================================
319367
320368
@@ -333,16 +381,16 @@ Several performance enhancements have been added:
333381
:keyword:`with` statements, looking up the :meth:`__enter__` and
334382
:meth:`__exit__` methods. (Contributed by Benjamin Peterson.)
335383

336-
* The garbage collector now performs better when many objects are
337-
being allocated without deallocating any. A full garbage collection
338-
pass is only performed when the middle generation has been collected
339-
10 times and when the number of survivor objects from the middle
340-
generation exceeds 10% of the number of objects in the oldest
341-
generation. The second condition was added to reduce the number
342-
of full garbage collections as the number of objects on the heap grows,
343-
avoiding quadratic performance when allocating very many objects.
344-
(Suggested by Martin von Loewis and implemented by Antoine Pitrou;
345-
:issue:`4074`.)
384+
* The garbage collector now performs better for one common usage
385+
pattern: when many objects are being allocated without deallocating
386+
any of them. This would previously take quadratic
387+
time for garbage collection, but now the number of full garbage collections
388+
is reduced as the number of objects on the heap grows.
389+
The new logic is to only perform a full garbage collection pass when
390+
the middle generation has been collected 10 times and when the
391+
number of survivor objects from the middle generation exceeds 10% of
392+
the number of objects in the oldest generation. (Suggested by Martin
393+
von Loewis and implemented by Antoine Pitrou; :issue:`4074`.)
346394

347395
* The garbage collector tries to avoid tracking simple containers
348396
which can't be part of a cycle. In Python 2.7, this is now true for
@@ -410,7 +458,6 @@ Several performance enhancements have been added:
410458
conversion function that supports arbitrary bases.
411459
(Patch by Gawain Bolton; :issue:`6713`.)
412460

413-
414461
.. ======================================================================
415462
416463
New and Improved Modules
@@ -488,12 +535,22 @@ changes, or look through the Subversion logs for all the details.
488535
(Added by Raymond Hettinger; :issue:`1818`.)
489536

490537
The :class:`deque` data type now exposes its maximum length as the
491-
read-only :attr:`maxlen` attribute. (Added by Raymond Hettinger.)
538+
read-only :attr:`maxlen` attribute, and has a
539+
:meth:`reverse` method that reverses the elements of the deque in-place.
540+
(Added by Raymond Hettinger.)
541+
542+
* The :mod:`copy` module's :func:`deepcopy` function will now
543+
correctly copy bound instance methods. (Implemented by
544+
Robert Collins; :issue:`1515`.)
492545

493546
* The :mod:`ctypes` module now always converts ``None`` to a C NULL
494547
pointer for arguments declared as pointers. (Changed by Thomas
495548
Heller; :issue:`4606`.)
496549

550+
* New method: the :mod:`datetime` module's :class:`timedelta` class
551+
gained a :meth:`total_seconds` method that returns the number of seconds
552+
in the duration. (Contributed by Brian Quinlan; :issue:`5788`.)
553+
497554
* New method: the :class:`Decimal` class gained a
498555
:meth:`from_float` class method that performs an exact conversion
499556
of a floating-point number to a :class:`Decimal`.
@@ -539,14 +596,24 @@ changes, or look through the Subversion logs for all the details.
539596
process, but instead simply not install the failing extension.
540597
(Contributed by Georg Brandl; :issue:`5583`.)
541598

542-
Issue #7457: added a read_pkg_file method to.distutils.dist.DistributionMetadata
543-
see file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
544-
(:issue:`7457`, added by Tarek).
599+
The :class:`distutils.dist.DistributionMetadata` class'
600+
:meth:`read_pkg_file` method will read the contents of a package's
601+
:file:`PKG-INFO` metadata file. For an example of its use,
602+
XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
603+
(Contributed by Tarek Ziade; :issue:`7457`.)
545604

546605
* The :class:`Fraction` class now accepts two rational numbers
547606
as arguments to its constructor.
548607
(Implemented by Mark Dickinson; :issue:`5812`.)
549608

609+
* The :mod:`ftplib` module gained the ability to establish secure FTP
610+
connections using TLS encapsulation of authentication as well as
611+
subsequent control and data transfers. This is provided by the new
612+
:class:`ftplib.FTP_TLS` class.
613+
(Contributed by Giampaolo Rodola', :issue:`2054`.) The :meth:`storbinary`
614+
method for binary uploads can now restart uploads thanks to an added
615+
*rest* parameter (patch by Pablo Mouzo; :issue:`6845`.)
616+
550617
* New function: the :mod:`gc` module's :func:`is_tracked` returns
551618
true if a given instance is tracked by the garbage collector, false
552619
otherwise. (Contributed by Antoine Pitrou; :issue:`4688`.)
@@ -627,8 +694,12 @@ changes, or look through the Subversion logs for all the details.
627694
with any object literal that decodes to a list of pairs.
628695
(Contributed by Raymond Hettinger; :issue:`5381`.)
629696

630-
* New functions: the :mod:`math` module now has
631-
a :func:`gamma` function.
697+
* New functions: the :mod:`math` module gained
698+
:func:`erf` and :func:`erfc` for the error function and the complementary error function,
699+
:func:`expm1` which computes ``e**x - 1`` with more precision than
700+
using :func:`exp` and subtracting 1,
701+
:func:`gamma` for the Gamma function, and
702+
:func:`lgamma` for the natural log of the Gamma function.
632703
(Contributed by Mark Dickinson and nirinA raseliarison; :issue:`3366`.)
633704

634705
* The :mod:`multiprocessing` module's :class:`Manager*` classes
@@ -640,6 +711,15 @@ changes, or look through the Subversion logs for all the details.
640711
* The :mod:`nntplib` module now supports IPv6 addresses.
641712
(Contributed by Derek Morr; :issue:`1664`.)
642713

714+
* New functions: the :mod:`os` module wraps the following POSIX system
715+
calls: :func:`getresgid` and :func:`getresuid`, which return the
716+
real, effective, and saved GIDs and UIDs;
717+
:func:`setresgid` and :func:`setresuid`, which set
718+
real, effective, and saved GIDs and UIDs to new values;
719+
:func:`initgroups`. (GID/UID functions
720+
contributed by Travis H.; :issue:`6508`. Support for initgroups added
721+
by Jean-Paul Calderone; :issue:`7333`.)
722+
643723
* The :mod:`pydoc` module now has help for the various symbols that Python
644724
uses. You can now do ``help('<<')`` or ``help('@')``, for example.
645725
(Contributed by David Laban; :issue:`4739`.)
@@ -728,12 +808,6 @@ changes, or look through the Subversion logs for all the details.
728808
:mod:`zipfile` now supports archiving empty directories and
729809
extracts them correctly. (Fixed by Kuba Wieczorek; :issue:`4710`.)
730810

731-
* The :mod:`ftplib` module gains the ability to establish secure FTP
732-
connections using TLS encapsulation of authentication as well as
733-
subsequent control and data transfers. This is provided by the new
734-
:class:`ftplib.FTP_TLS` class.
735-
(Contributed by Giampaolo Rodola', :issue:`2054`.)
736-
737811
.. ======================================================================
738812
.. whole new modules get described in subsections here
739813
@@ -855,7 +929,7 @@ importlib: Importing Modules
855929
Python 3.1 includes the :mod:`importlib` package, a re-implementation
856930
of the logic underlying Python's :keyword:`import` statement.
857931
:mod:`importlib` is useful for implementors of Python interpreters and
858-
to user who wish to write new importers that can participate in the
932+
to users who wish to write new importers that can participate in the
859933
import process. Python 2.7 doesn't contain the complete
860934
:mod:`importlib` package, but instead has a tiny subset that contains
861935
a single function, :func:`import_module`.
@@ -934,12 +1008,23 @@ Changes to Python's build process and to the C API include:
9341008
extensions needed to call :cfunc:`PyCode_New`, which had many
9351009
more arguments. (Added by Jeffrey Yasskin.)
9361010

1011+
* New function: :cfunc:`PyErr_NewExceptionWithDoc` creates a new
1012+
exception class, just as the existing :cfunc:`PyErr_NewException` does,
1013+
but takes an extra ``char *`` argument containing the docstring for the
1014+
new exception class. (Added by the 'lekma' user on the Python bug tracker;
1015+
:issue:`7033`.)
1016+
9371017
* New function: :cfunc:`PyFrame_GetLineNumber` takes a frame object
9381018
and returns the line number that the frame is currently executing.
9391019
Previously code would need to get the index of the bytecode
9401020
instruction currently executing, and then look up the line number
9411021
corresponding to that address. (Added by Jeffrey Yasskin.)
9421022

1023+
* New function: :cfunc:`PyLong_AsLongAndOverflow` approximates a Python long
1024+
integer as a C :ctype:`long`. If the number is too large to fit into
1025+
a :ctype:`long`, an *overflow* flag is set and returned to the caller.
1026+
(Contributed by Case Van Horsen; :issue:`7528`.)
1027+
9431028
* New macros: the Python header files now define the following macros:
9441029
:cmacro:`Py_ISALNUM`,
9451030
:cmacro:`Py_ISALPHA`,
@@ -958,6 +1043,12 @@ Changes to Python's build process and to the C API include:
9581043

9591044
.. XXX these macros don't seem to be described in the c-api docs.
9601045
1046+
* New format codes: the :cfunc:`PyFormat_FromString`,
1047+
:cfunc:`PyFormat_FromStringV`, and :cfunc:`PyErr_Format` now
1048+
accepts ``%lld`` and ``%llu`` format codes for displaying values of
1049+
C's :ctype:`long long` types.
1050+
(Contributed by Mark Dickinson; :issue:`7228`.)
1051+
9611052
* The complicated interaction between threads and process forking has
9621053
been changed. Previously, the child process created by
9631054
:func:`os.fork` might fail because the child is created with only a
@@ -992,6 +1083,12 @@ Changes to Python's build process and to the C API include:
9921083
* The build process now supports Subversion 1.7. (Contributed by
9931084
Arfrever Frehtes Taifersar Arahesis; :issue:`6094`.)
9941085

1086+
* Compiling Python with the :option:`--with-valgrind` option will now
1087+
disable the pymalloc allocator, which is difficult for the Valgrind to
1088+
analyze correctly. Valgrind will therefore be better at detecting
1089+
memory leaks and overruns. (Contributed by James Henstridge; :issue:`2422`.)
1090+
1091+
9951092
.. ======================================================================
9961093
9971094
Port-Specific Changes: Windows
@@ -1011,6 +1108,10 @@ Port-Specific Changes: Windows
10111108
* The :func:`os.listdir` function now correctly fails
10121109
for an empty path. (Fixed by Hirokazu Yamamoto; :issue:`5913`.)
10131110

1111+
* The :mod:`mimelib` module will now read the MIME database from
1112+
the Windows registry when initializing.
1113+
(Patch by Gabriel Genellina; :issue:`4969`.)
1114+
10141115
.. ======================================================================
10151116
10161117
Port-Specific Changes: Mac OS X
@@ -1070,6 +1171,10 @@ that may require changes to your code:
10701171
affects new-style classes (derived from :class:`object`) and C extension
10711172
types. (:issue:`6101`.)
10721173

1174+
* The :meth:`readline` method of :class:`StringIO` objects now does
1175+
nothing when a negative length is requested, as other file-like
1176+
objects do. (:issue:`7348`).
1177+
10731178
.. ======================================================================
10741179
10751180

0 commit comments

Comments
 (0)