@@ -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
7782One porting change: the :option: `-3 ` switch now automatically
7883enables 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::
@@ -318,6 +354,10 @@ Some smaller changes made to the core Python language are:
318354 supported. (Contributed by Alexander Belchenko and Amaury Forgeot
319355 d'Arc; :issue: `1616979 `.)
320356
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+
321361* Extra parentheses in function definitions are illegal in Python 3.x,
322362 meaning that you get a syntax error from ``def f((x)): pass ``. In
323363 Python3-warning mode, Python 2.7 will now warn about this odd usage.
@@ -499,10 +539,18 @@ changes, or look through the Subversion logs for all the details.
499539 :meth: `reverse ` method that reverses the elements of the deque in-place.
500540 (Added by Raymond Hettinger.)
501541
542+ * The :mod: `copy ` module's :func: `deepcopy ` function will now
543+ correctly copy bound instance methods. (Implemented by
544+ Robert Collins; :issue: `1515 `.)
545+
502546* The :mod: `ctypes ` module now always converts ``None `` to a C NULL
503547 pointer for arguments declared as pointers. (Changed by Thomas
504548 Heller; :issue: `4606 `.)
505549
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+
506554* New method: the :class: `Decimal ` class gained a
507555 :meth: `from_float ` class method that performs an exact conversion
508556 of a floating-point number to a :class: `Decimal `.
@@ -550,7 +598,7 @@ changes, or look through the Subversion logs for all the details.
550598
551599 The :class: `distutils.dist.DistributionMetadata ` class'
552600 :meth: `read_pkg_file ` method will read the contents of a package's
553- metadata file. For an example of its use,
601+ :file: ` PKG-INFO ` metadata file. For an example of its use,
554602 XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
555603 (Contributed by Tarek Ziade; :issue: `7457 `.)
556604
@@ -667,8 +715,10 @@ changes, or look through the Subversion logs for all the details.
667715 calls: :func: `getresgid ` and :func: `getresuid `, which return the
668716 real, effective, and saved GIDs and UIDs;
669717 :func: `setresgid ` and :func: `setresuid `, which set
670- real, effective, and saved GIDs and UIDs to new values. (Contributed
671- by Travis H.; :issue: `6508 `.)
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 `.)
672722
673723* The :mod: `pydoc ` module now has help for the various symbols that Python
674724 uses. You can now do ``help('<<') `` or ``help('@') ``, for example.
@@ -970,6 +1020,11 @@ Changes to Python's build process and to the C API include:
9701020 instruction currently executing, and then look up the line number
9711021 corresponding to that address. (Added by Jeffrey Yasskin.)
9721022
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+
9731028* New macros: the Python header files now define the following macros:
9741029 :cmacro: `Py_ISALNUM `,
9751030 :cmacro: `Py_ISALPHA `,
@@ -988,6 +1043,12 @@ Changes to Python's build process and to the C API include:
9881043
9891044 .. XXX these macros don't seem to be described in the c-api docs.
9901045
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+
9911052* The complicated interaction between threads and process forking has
9921053 been changed. Previously, the child process created by
9931054 :func: `os.fork ` might fail because the child is created with only a
@@ -1047,6 +1108,10 @@ Port-Specific Changes: Windows
10471108* The :func: `os.listdir ` function now correctly fails
10481109 for an empty path. (Fixed by Hirokazu Yamamoto; :issue: `5913 `.)
10491110
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+
10501115.. ======================================================================
10511116
10521117 Port-Specific Changes: Mac OS X
0 commit comments