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
32a4c714
Commit
32a4c714
authored
Jun 20, 2007
by
Walter Dörwald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch by Ron Adam: Don't use u prefix in unicode error messages
and remove u prefix from some comments in test_codecs.py.
parent
31f72d72
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
19 deletions
+19
-19
Lib/test/test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+9
-9
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+4
-4
Objects/exceptions.c
Objects/exceptions.c
+6
-6
No files found.
Lib/test/test_codeccallbacks.py
View file @
32a4c714
...
...
@@ -329,7 +329,7 @@ class CodecCallbackTest(unittest.TestCase):
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
"g
\
xfc
rk"
,
1
,
2
,
"ouch"
],
"'ascii' codec can't encode character
u
'
\
\
xfc' in position 1: ouch"
"'ascii' codec can't encode character '
\
\
xfc' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
...
...
@@ -339,23 +339,23 @@ class CodecCallbackTest(unittest.TestCase):
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
"
\
xfc
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character
u
'
\
\
xfc' in position 0: ouch"
"'ascii' codec can't encode character '
\
\
xfc' in position 0: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
"
\
u0100
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character
u
'
\
\
u0100' in position 0: ouch"
"'ascii' codec can't encode character '
\
\
u0100' in position 0: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
"
\
uffff
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character
u
'
\
\
uffff' in position 0: ouch"
"'ascii' codec can't encode character '
\
\
uffff' in position 0: ouch"
)
if
sys
.
maxunicode
>
0xffff
:
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
"
\
U00010000
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character
u
'
\
\
U00010000' in position 0: ouch"
"'ascii' codec can't encode character '
\
\
U00010000' in position 0: ouch"
)
def
test_unicodedecodeerror
(
self
):
...
...
@@ -374,23 +374,23 @@ class CodecCallbackTest(unittest.TestCase):
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
"g
\
xfc
rk"
,
1
,
2
,
"ouch"
],
"can't translate character
u
'
\
\
xfc' in position 1: ouch"
"can't translate character '
\
\
xfc' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
"g
\
u0100
rk"
,
1
,
2
,
"ouch"
],
"can't translate character
u
'
\
\
u0100' in position 1: ouch"
"can't translate character '
\
\
u0100' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
"g
\
uffff
rk"
,
1
,
2
,
"ouch"
],
"can't translate character
u
'
\
\
uffff' in position 1: ouch"
"can't translate character '
\
\
uffff' in position 1: ouch"
)
if
sys
.
maxunicode
>
0xffff
:
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
"g
\
U00010000
rk"
,
1
,
2
,
"ouch"
],
"can't translate character
u
'
\
\
U00010000' in position 1: ouch"
"can't translate character '
\
\
U00010000' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
...
...
Lib/test/test_codecs.py
View file @
32a4c714
...
...
@@ -459,10 +459,10 @@ class UTF8SigTest(ReadTest):
""
,
"
\
ufeff
"
,
# Second BOM has been read and emitted
"
\
ufeff
\
x00
"
,
# "\x00" read and emitted
"
\
ufeff
\
x00
"
,
# First byte of encoded
u
"\xff" read
"
\
ufeff
\
x00
\
xff
"
,
# Second byte of encoded
u
"\xff" read
"
\
ufeff
\
x00
\
xff
"
,
# First byte of encoded
u
"\u07ff" read
"
\
ufeff
\
x00
\
xff
\
u07ff
"
,
# Second byte of encoded
u
"\u07ff" read
"
\
ufeff
\
x00
"
,
# First byte of encoded "\xff" read
"
\
ufeff
\
x00
\
xff
"
,
# Second byte of encoded "\xff" read
"
\
ufeff
\
x00
\
xff
"
,
# First byte of encoded "\u07ff" read
"
\
ufeff
\
x00
\
xff
\
u07ff
"
,
# Second byte of encoded "\u07ff" read
"
\
ufeff
\
x00
\
xff
\
u07ff
"
,
"
\
ufeff
\
x00
\
xff
\
u07ff
"
,
"
\
ufeff
\
x00
\
xff
\
u07ff
\
u0800
"
,
...
...
Objects/exceptions.c
View file @
32a4c714
...
...
@@ -1289,11 +1289,11 @@ UnicodeEncodeError_str(PyObject *self)
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
uself
->
object
)[
uself
->
start
];
const
char
*
fmt
;
if
(
badchar
<=
0xff
)
fmt
=
"'%U' codec can't encode character
u
'
\\
x%02x' in position %zd: %U"
;
fmt
=
"'%U' codec can't encode character '
\\
x%02x' in position %zd: %U"
;
else
if
(
badchar
<=
0xffff
)
fmt
=
"'%U' codec can't encode character
u
'
\\
u%04x' in position %zd: %U"
;
fmt
=
"'%U' codec can't encode character '
\\
u%04x' in position %zd: %U"
;
else
fmt
=
"'%U' codec can't encode character
u
'
\\
U%08x' in position %zd: %U"
;
fmt
=
"'%U' codec can't encode character '
\\
U%08x' in position %zd: %U"
;
return
PyUnicode_FromFormat
(
fmt
,
((
PyUnicodeErrorObject
*
)
self
)
->
encoding
,
...
...
@@ -1440,11 +1440,11 @@ UnicodeTranslateError_str(PyObject *self)
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
uself
->
object
)[
uself
->
start
];
const
char
*
fmt
;
if
(
badchar
<=
0xff
)
fmt
=
"can't translate character
u
'
\\
x%02x' in position %zd: %U"
;
fmt
=
"can't translate character '
\\
x%02x' in position %zd: %U"
;
else
if
(
badchar
<=
0xffff
)
fmt
=
"can't translate character
u
'
\\
u%04x' in position %zd: %U"
;
fmt
=
"can't translate character '
\\
u%04x' in position %zd: %U"
;
else
fmt
=
"can't translate character
u
'
\\
U%08x' in position %zd: %U"
;
fmt
=
"can't translate character '
\\
U%08x' in position %zd: %U"
;
return
PyUnicode_FromFormat
(
fmt
,
badchar
,
...
...
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