summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-08-16 13:22:20 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-08-16 13:22:20 (GMT)
commitefd68c789e9dc68839040364d63d9ff1d02b41d3 (patch)
tree73c20c3c74eb194e946b5f01272d4f307754745f /Doc/whatsnew
parent581795902ded7050522e9af61d997b6ee0e64188 (diff)
downloadcpython-efd68c789e9dc68839040364d63d9ff1d02b41d3.zip
cpython-efd68c789e9dc68839040364d63d9ff1d02b41d3.tar.gz
cpython-efd68c789e9dc68839040364d63d9ff1d02b41d3.tar.bz2
Add UnicodeWarning
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/whatsnew25.tex34
1 files changed, 34 insertions, 0 deletions
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex
index dcb6ab1..aa2a399 100644
--- a/Doc/whatsnew/whatsnew25.tex
+++ b/Doc/whatsnew/whatsnew25.tex
@@ -1184,6 +1184,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
@@ -2423,6 +2452,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