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
14e10a19
Kaydet (Commit)
14e10a19
authored
May 18, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #24102: Fixed exception type checking in standard error handlers.
üst
51dbc9a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
8 deletions
+31
-8
test_codeccallbacks.py
Lib/test/test_codeccallbacks.py
+20
-0
NEWS
Misc/NEWS
+2
-0
codecs.c
Python/codecs.c
+9
-8
No files found.
Lib/test/test_codeccallbacks.py
Dosyayı görüntüle @
14e10a19
...
...
@@ -836,6 +836,26 @@ class CodecCallbackTest(unittest.TestCase):
text
=
u'abc<def>ghi'
*
n
text
.
translate
(
charmap
)
def
test_fake_error_class
(
self
):
handlers
=
[
codecs
.
strict_errors
,
codecs
.
ignore_errors
,
codecs
.
replace_errors
,
codecs
.
backslashreplace_errors
,
codecs
.
xmlcharrefreplace_errors
,
]
for
cls
in
UnicodeEncodeError
,
UnicodeDecodeError
,
UnicodeTranslateError
:
class
FakeUnicodeError
(
str
):
__class__
=
cls
for
handler
in
handlers
:
self
.
assertRaises
(
TypeError
,
handler
,
FakeUnicodeError
())
class
FakeUnicodeError
(
Exception
):
__class__
=
cls
for
handler
in
handlers
:
with
self
.
assertRaises
((
TypeError
,
FakeUnicodeError
)):
handler
(
FakeUnicodeError
())
def
test_main
():
test
.
test_support
.
run_unittest
(
CodecCallbackTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
14e10a19
...
...
@@ -10,6 +10,8 @@ What's New in Python 2.7.11?
Core and Builtins
-----------------
- Issue #24102: Fixed exception type checking in standard error handlers.
Library
-------
...
...
Python/codecs.c
Dosyayı görüntüle @
14e10a19
...
...
@@ -472,15 +472,16 @@ PyObject *PyCodec_StrictErrors(PyObject *exc)
PyObject
*
PyCodec_IgnoreErrors
(
PyObject
*
exc
)
{
Py_ssize_t
end
;
if
(
PyObject_IsInstance
(
exc
,
PyExc_UnicodeEncodeError
))
{
if
(
PyObject_TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeEncodeError
))
{
if
(
PyUnicodeEncodeError_GetEnd
(
exc
,
&
end
))
return
NULL
;
}
else
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeDecodeError
))
{
else
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeDecodeError
))
{
if
(
PyUnicodeDecodeError_GetEnd
(
exc
,
&
end
))
return
NULL
;
}
else
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeTranslateError
))
{
else
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeTranslateError
))
{
if
(
PyUnicodeTranslateError_GetEnd
(
exc
,
&
end
))
return
NULL
;
}
...
...
@@ -500,7 +501,7 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
Py_ssize_t
end
;
Py_ssize_t
i
;
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeEncodeError
))
{
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeEncodeError
))
{
PyObject
*
res
;
Py_UNICODE
*
p
;
if
(
PyUnicodeEncodeError_GetStart
(
exc
,
&
start
))
...
...
@@ -517,13 +518,13 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
Py_DECREF
(
res
);
return
restuple
;
}
else
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeDecodeError
))
{
else
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeDecodeError
))
{
Py_UNICODE
res
=
Py_UNICODE_REPLACEMENT_CHARACTER
;
if
(
PyUnicodeDecodeError_GetEnd
(
exc
,
&
end
))
return
NULL
;
return
Py_BuildValue
(
"(u#n)"
,
&
res
,
(
Py_ssize_t
)
1
,
end
);
}
else
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeTranslateError
))
{
else
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeTranslateError
))
{
PyObject
*
res
;
Py_UNICODE
*
p
;
if
(
PyUnicodeTranslateError_GetStart
(
exc
,
&
start
))
...
...
@@ -548,7 +549,7 @@ PyObject *PyCodec_ReplaceErrors(PyObject *exc)
PyObject
*
PyCodec_XMLCharRefReplaceErrors
(
PyObject
*
exc
)
{
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeEncodeError
))
{
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeEncodeError
))
{
PyObject
*
restuple
;
PyObject
*
object
;
Py_ssize_t
start
;
...
...
@@ -673,7 +674,7 @@ static Py_UNICODE hexdigits[] = {
PyObject
*
PyCodec_BackslashReplaceErrors
(
PyObject
*
exc
)
{
if
(
PyObject_
IsInstance
(
exc
,
PyExc_UnicodeEncodeError
))
{
if
(
PyObject_
TypeCheck
(
exc
,
(
PyTypeObject
*
)
PyExc_UnicodeEncodeError
))
{
PyObject
*
restuple
;
PyObject
*
object
;
Py_ssize_t
start
;
...
...
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