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
71cf91cc
Kaydet (Commit)
71cf91cc
authored
Şub 01, 2015
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge 3.4 (#23369)
üst
e7405047
3675cd9d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
test_encode_basestring_ascii.py
Lib/test/test_json/test_encode_basestring_ascii.py
+8
-1
NEWS
Misc/NEWS
+3
-0
_json.c
Modules/_json.c
+11
-4
No files found.
Lib/test/test_json/test_encode_basestring_ascii.py
Dosyayı görüntüle @
71cf91cc
from
collections
import
OrderedDict
from
test.test_json
import
PyTest
,
CTest
from
test.support
import
bigaddrspacetest
CASES
=
[
...
...
@@ -38,4 +39,10 @@ class TestEncodeBasestringAscii:
class
TestPyEncodeBasestringAscii
(
TestEncodeBasestringAscii
,
PyTest
):
pass
class
TestCEncodeBasestringAscii
(
TestEncodeBasestringAscii
,
CTest
):
pass
class
TestCEncodeBasestringAscii
(
TestEncodeBasestringAscii
,
CTest
):
@bigaddrspacetest
def
test_overflow
(
self
):
s
=
"
\uffff
"
*
((
2
**
32
)
//
6
+
1
)
with
self
.
assertRaises
(
OverflowError
):
self
.
json
.
encoder
.
encode_basestring_ascii
(
s
)
Misc/NEWS
Dosyayı görüntüle @
71cf91cc
...
...
@@ -229,6 +229,9 @@ Library
- Issue #23326: Removed __ne__ implementations. Since fixing default __ne__
implementation in issue #21408 they are redundant.
- Issue #23369: Fixed possible integer overflow in
_json.encode_basestring_ascii.
- Issue #23353: Fix the exception handling of generators in
PyEval_EvalFrameEx(). At entry, save or swap the exception state even if
PyEval_EvalFrameEx() is called with throwflag=0. At exit, the exception state
...
...
Modules/_json.c
Dosyayı görüntüle @
71cf91cc
...
...
@@ -182,17 +182,24 @@ ascii_escape_unicode(PyObject *pystr)
/* Compute the output size */
for
(
i
=
0
,
output_size
=
2
;
i
<
input_chars
;
i
++
)
{
Py_UCS4
c
=
PyUnicode_READ
(
kind
,
input
,
i
);
if
(
S_CHAR
(
c
))
output_size
++
;
Py_ssize_t
d
;
if
(
S_CHAR
(
c
))
{
d
=
1
;
}
else
{
switch
(
c
)
{
case
'\\'
:
case
'"'
:
case
'\b'
:
case
'\f'
:
case
'\n'
:
case
'\r'
:
case
'\t'
:
output_size
+
=
2
;
break
;
d
=
2
;
break
;
default:
output_size
+
=
c
>=
0x10000
?
12
:
6
;
d
=
c
>=
0x10000
?
12
:
6
;
}
}
if
(
output_size
>
PY_SSIZE_T_MAX
-
d
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"string is too long to escape"
);
return
NULL
;
}
output_size
+=
d
;
}
rval
=
PyUnicode_New
(
output_size
,
127
);
...
...
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