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
1e28513d
Kaydet (Commit)
1e28513d
authored
Ock 12, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix test_bigaddrspace (some tests didn't trigger the expected MemoryError)
üst
98c62bd1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
25 deletions
+43
-25
test_bigaddrspace.py
Lib/test/test_bigaddrspace.py
+43
-25
No files found.
Lib/test/test_bigaddrspace.py
Dosyayı görüntüle @
1e28513d
...
@@ -23,25 +23,34 @@ class BytesTest(unittest.TestCase):
...
@@ -23,25 +23,34 @@ class BytesTest(unittest.TestCase):
# Allocate a bytestring that's near the maximum size allowed by
# Allocate a bytestring that's near the maximum size allowed by
# the address space, and then try to build a new, larger one through
# the address space, and then try to build a new, larger one through
# concatenation.
# concatenation.
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
try
:
self
.
assertRaises
(
OverflowError
,
operator
.
add
,
x
,
b
"x"
*
128
)
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
self
.
assertRaises
(
OverflowError
,
operator
.
add
,
x
,
b
"x"
*
128
)
finally
:
x
=
None
@bigaddrspacetest
@bigaddrspacetest
def
test_optimized_concat
(
self
):
def
test_optimized_concat
(
self
):
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
try
:
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
with
self
.
assertRaises
(
OverflowError
)
as
cm
:
with
self
.
assertRaises
(
OverflowError
)
as
cm
:
# this statement uses
a fast path in ceval.c
# this statement used
a fast path in ceval.c
x
=
x
+
b
"x"
*
128
x
=
x
+
b
"x"
*
128
with
self
.
assertRaises
(
OverflowError
)
as
cm
:
with
self
.
assertRaises
(
OverflowError
)
as
cm
:
# this statement uses a fast path in ceval.c
# this statement used a fast path in ceval.c
x
+=
b
"x"
*
128
x
+=
b
"x"
*
128
finally
:
x
=
None
@bigaddrspacetest
@bigaddrspacetest
def
test_repeat
(
self
):
def
test_repeat
(
self
):
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
try
:
self
.
assertRaises
(
OverflowError
,
operator
.
mul
,
x
,
128
)
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
self
.
assertRaises
(
OverflowError
,
operator
.
mul
,
x
,
128
)
finally
:
x
=
None
class
StrTest
(
unittest
.
TestCase
):
class
StrTest
(
unittest
.
TestCase
):
...
@@ -50,28 +59,37 @@ class StrTest(unittest.TestCase):
...
@@ -50,28 +59,37 @@ class StrTest(unittest.TestCase):
@bigaddrspacetest
@bigaddrspacetest
def
test_concat
(
self
):
def
test_concat
(
self
):
# Create a string half the size that would fill the address space
try
:
x
=
"x"
*
(
MAX_Py_ssize_t
//
(
2
*
self
.
unicodesize
))
# Create a string that would fill almost the address space
# Unicode objects trigger MemoryError in case an operation that's
x
=
"x"
*
int
(
MAX_Py_ssize_t
//
(
1.1
*
self
.
unicodesize
))
# going to cause a size overflow is executed
# Unicode objects trigger MemoryError in case an operation that's
self
.
assertRaises
(
MemoryError
,
operator
.
add
,
x
,
x
)
# going to cause a size overflow is executed
self
.
assertRaises
(
MemoryError
,
operator
.
add
,
x
,
x
)
finally
:
x
=
None
@bigaddrspacetest
@bigaddrspacetest
def
test_optimized_concat
(
self
):
def
test_optimized_concat
(
self
):
x
=
"x"
*
(
MAX_Py_ssize_t
//
(
2
*
self
.
unicodesize
))
try
:
x
=
"x"
*
int
(
MAX_Py_ssize_t
//
(
1.1
*
self
.
unicodesize
))
with
self
.
assertRaises
(
MemoryError
)
as
cm
:
with
self
.
assertRaises
(
MemoryError
)
as
cm
:
# this statement uses a fast path in ceval.c
# this statement uses a fast path in ceval.c
x
=
x
+
x
x
=
x
+
x
with
self
.
assertRaises
(
MemoryError
)
as
cm
:
with
self
.
assertRaises
(
MemoryError
)
as
cm
:
# this statement uses a fast path in ceval.c
# this statement uses a fast path in ceval.c
x
+=
x
x
+=
x
finally
:
x
=
None
@bigaddrspacetest
@bigaddrspacetest
def
test_repeat
(
self
):
def
test_repeat
(
self
):
x
=
"x"
*
(
MAX_Py_ssize_t
//
(
2
*
self
.
unicodesize
))
try
:
self
.
assertRaises
(
MemoryError
,
operator
.
mul
,
x
,
2
)
x
=
"x"
*
int
(
MAX_Py_ssize_t
//
(
1.1
*
self
.
unicodesize
))
self
.
assertRaises
(
MemoryError
,
operator
.
mul
,
x
,
2
)
finally
:
x
=
None
def
test_main
():
def
test_main
():
...
...
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