Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
db000c81
Commit
db000c81
authored
Aug 16, 2006
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add UnicodeWarning
parent
6661998e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
Doc/whatsnew/whatsnew25.tex
Doc/whatsnew/whatsnew25.tex
+34
-0
No files found.
Doc/whatsnew/whatsnew25.tex
View file @
db000c81
...
@@ -1184,6 +1184,35 @@ a line like this near the top of the source file:
...
@@ -1184,6 +1184,35 @@ a line like this near the top of the source file:
# -*- coding: latin1 -*-
# -*- coding: latin1 -*-
\end{verbatim}
\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
\item
One error that Python programmers sometimes make is forgetting
to include an
\file
{__
init
__
.py
}
module in a package directory.
to include an
\file
{__
init
__
.py
}
module in a package directory.
Debugging this mistake can be confusing, and usually requires running
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
...
@@ -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
described in section~
\ref
{
pep-342
}
, it's now possible
for
\member
{
gi
_
frame
}
to be
\code
{
None
}
.
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
\item
Library: the
\module
{
csv
}
module is now stricter about multi-line quoted
fields. If your files contain newlines embedded within fields, the
fields. If your files contain newlines embedded within fields, the
input should be split into lines in a manner which preserves the
input should be split into lines in a manner which preserves the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment