diff options
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/whatsnew25.tex | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex index dcb6ab1..bf939c0 100644 --- a/Doc/whatsnew/whatsnew25.tex +++ b/Doc/whatsnew/whatsnew25.tex @@ -5,7 +5,7 @@ % Fix XXX comments \title{What's New in Python 2.5} -\release{0.9} +\release{1.0} \author{A.M. Kuchling} \authoraddress{\email{amk@amk.ca}} @@ -40,15 +40,14 @@ Python's semantics. As well as the language and library additions, other improvements and bugfixes were made throughout the source tree. A search through the -SVN change logs finds there were 334 patches applied and 443 bugs +SVN change logs finds there were 353 patches applied and 458 bugs fixed between Python 2.4 and 2.5. (Both figures are likely to be underestimates.) This article doesn't try to be a complete specification of the new features; instead changes are briefly introduced using helpful examples. For full details, you should always refer to the -documentation for Python 2.5. -% XXX add hyperlink when the documentation becomes available online. +documentation for Python 2.5 at \url{http://docs.python.org}. If you want to understand the complete implementation and design rationale, refer to the PEP for a particular new feature. @@ -751,7 +750,6 @@ either committed, meaning that all the changes are written into the database, or rolled back, meaning that the changes are all discarded and the database is unchanged. See any database textbook for more information.) -% XXX find a shorter reference? Let's assume there's an object representing a database connection. Our goal will be to let the user write code like this: @@ -1184,6 +1182,35 @@ a line like this near the top of the source file: # -*- coding: latin1 -*- \end{verbatim} +\item A new warning, \class{UnicodeWarning}, is triggered when +you attempt to compare a Unicode string and an 8-bit string +that can't be converted to Unicode using the default ASCII encoding. +The result of the comparison is false: + +\begin{verbatim} +>>> chr(128) == unichr(128) # Can't convert chr(128) to Unicode +__main__:1: UnicodeWarning: Unicode equal comparison failed + to convert both arguments to Unicode - interpreting them + as being unequal +False +>>> chr(127) == unichr(127) # chr(127) can be converted +True +\end{verbatim} + +Previously this would raise a \class{UnicodeDecodeError} exception, +but in 2.5 this could result in puzzling problems when accessing a +dictionary. If you looked up \code{unichr(128)} and \code{chr(128)} +was being used as a key, you'd get a \class{UnicodeDecodeError} +exception. Other changes in 2.5 resulted in this exception being +raised instead of suppressed by the code in \file{dictobject.c} that +implements dictionaries. + +Raising an exception for such a comparison is strictly correct, but +the change might have broken code, so instead +\class{UnicodeWarning} was introduced. + +(Implemented by Marc-Andr\'e Lemburg.) + \item One error that Python programmers sometimes make is forgetting to include an \file{__init__.py} module in a package directory. Debugging this mistake can be confusing, and usually requires running @@ -1305,9 +1332,6 @@ they exist or not so that the interpreter makes fewer \end{itemize} -The net result of the 2.5 optimizations is that Python 2.5 runs the -pystone benchmark around XXX\% faster than Python 2.4. - %====================================================================== \section{New, Improved, and Removed Modules\label{modules}} @@ -2423,6 +2447,11 @@ was always a frame object. Because of the \pep{342} changes described in section~\ref{pep-342}, it's now possible for \member{gi_frame} to be \code{None}. +\item A new warning, \class{UnicodeWarning}, is triggered when +you attempt to compare a Unicode string and an 8-bit string that can't +be converted to Unicode using the default ASCII encoding. Previously +such comparisons would raise a \class{UnicodeDecodeError} exception. + \item Library: the \module{csv} module is now stricter about multi-line quoted fields. If your files contain newlines embedded within fields, the input should be split into lines in a manner which preserves the |