Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a54b92b2
Kaydet (Commit)
a54b92b2
authored
Agu 12, 2003
tarafından
Walter Dörwald
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add a unicode prefix to the characters in the UnicodeEncodeError and
UnicodeTranslateError message.
üst
fd196bd2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+9
-9
exceptions.c
Python/exceptions.c
+6
-6
No files found.
Lib/test/test_codeccallbacks.py
Dosyayı görüntüle @
a54b92b2
...
...
@@ -258,7 +258,7 @@ class CodecCallbackTest(unittest.TestCase):
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
u"g
\xfc
rk"
,
1
,
2
,
"ouch"
],
"'ascii' codec can't encode character '
\\
xfc' in position 1: ouch"
"'ascii' codec can't encode character
u
'
\\
xfc' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
...
...
@@ -268,23 +268,23 @@ class CodecCallbackTest(unittest.TestCase):
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
u"
\xfc
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character '
\\
xfc' in position 0: ouch"
"'ascii' codec can't encode character
u
'
\\
xfc' in position 0: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
u"
\u0100
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character '
\\
u0100' in position 0: ouch"
"'ascii' codec can't encode character
u
'
\\
u0100' in position 0: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
u"
\uffff
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character '
\\
uffff' in position 0: ouch"
"'ascii' codec can't encode character
u
'
\\
uffff' in position 0: ouch"
)
if
sys
.
maxunicode
>
0xffff
:
self
.
check_exceptionobjectargs
(
UnicodeEncodeError
,
[
"ascii"
,
u"
\U00010000
x"
,
0
,
1
,
"ouch"
],
"'ascii' codec can't encode character '
\\
U00010000' in position 0: ouch"
"'ascii' codec can't encode character
u
'
\\
U00010000' in position 0: ouch"
)
def
test_unicodedecodeerror
(
self
):
...
...
@@ -303,23 +303,23 @@ class CodecCallbackTest(unittest.TestCase):
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
u"g
\xfc
rk"
,
1
,
2
,
"ouch"
],
"can't translate character '
\\
xfc' in position 1: ouch"
"can't translate character
u
'
\\
xfc' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
u"g
\u0100
rk"
,
1
,
2
,
"ouch"
],
"can't translate character '
\\
u0100' in position 1: ouch"
"can't translate character
u
'
\\
u0100' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
u"g
\uffff
rk"
,
1
,
2
,
"ouch"
],
"can't translate character '
\\
uffff' in position 1: ouch"
"can't translate character
u
'
\\
uffff' in position 1: ouch"
)
if
sys
.
maxunicode
>
0xffff
:
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
[
u"g
\U00010000
rk"
,
1
,
2
,
"ouch"
],
"can't translate character '
\\
U00010000' in position 1: ouch"
"can't translate character
u
'
\\
U00010000' in position 1: ouch"
)
self
.
check_exceptionobjectargs
(
UnicodeTranslateError
,
...
...
Python/exceptions.c
Dosyayı görüntüle @
a54b92b2
...
...
@@ -1254,11 +1254,11 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
objectObj
)[
start
];
char
*
format
;
if
(
badchar
<=
0xff
)
format
=
"'%.400s' codec can't encode character '
\\
x%02x' in position %d: %.400s"
;
format
=
"'%.400s' codec can't encode character
u
'
\\
x%02x' in position %d: %.400s"
;
else
if
(
badchar
<=
0xffff
)
format
=
"'%.400s' codec can't encode character '
\\
u%04x' in position %d: %.400s"
;
format
=
"'%.400s' codec can't encode character
u
'
\\
u%04x' in position %d: %.400s"
;
else
format
=
"'%.400s' codec can't encode character '
\\
U%08x' in position %d: %.400s"
;
format
=
"'%.400s' codec can't encode character
u
'
\\
U%08x' in position %d: %.400s"
;
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
format
,
PyString_AS_STRING
(
encodingObj
),
...
...
@@ -1449,11 +1449,11 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
int
badchar
=
(
int
)
PyUnicode_AS_UNICODE
(
objectObj
)[
start
];
char
*
format
;
if
(
badchar
<=
0xff
)
format
=
"can't translate character '
\\
x%02x' in position %d: %.400s"
;
format
=
"can't translate character
u
'
\\
x%02x' in position %d: %.400s"
;
else
if
(
badchar
<=
0xffff
)
format
=
"can't translate character '
\\
u%04x' in position %d: %.400s"
;
format
=
"can't translate character
u
'
\\
u%04x' in position %d: %.400s"
;
else
format
=
"can't translate character '
\\
U%08x' in position %d: %.400s"
;
format
=
"can't translate character
u
'
\\
U%08x' in position %d: %.400s"
;
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
format
,
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