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
99c4830d
Kaydet (Commit)
99c4830d
authored
Kas 04, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #3699: Fix test_bigaddrspace and extend it to test bytestrings
as well as unicode strings. Initial patch by Sandro Tosi.
üst
aeb6ceea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
23 deletions
+63
-23
test_bigaddrspace.py
Lib/test/test_bigaddrspace.py
+60
-23
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_bigaddrspace.py
Dosyayı görüntüle @
99c4830d
"""
These tests are meant to exercise that requests to create objects bigger
than what the address space allows are properly met with an OverflowError
(rather than crash weirdly).
Primarily, this means 32-bit builds with at least 2 GB of available memory.
You need to pass the -M option to regrtest (e.g. "-M 2.1G") for tests to
be enabled.
"""
from
test
import
support
from
test
import
support
from
test.support
import
bigaddrspacetest
,
MAX_Py_ssize_t
from
test.support
import
bigaddrspacetest
,
MAX_Py_ssize_t
...
@@ -6,39 +16,66 @@ import operator
...
@@ -6,39 +16,66 @@ import operator
import
sys
import
sys
class
BytesTest
(
unittest
.
TestCase
):
@bigaddrspacetest
def
test_concat
(
self
):
# Allocate a bytestring that's near the maximum size allowed by
# the address space, and then try to build a new, larger one through
# concatenation.
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
self
.
assertRaises
(
OverflowError
,
operator
.
add
,
x
,
b
"x"
*
128
)
@bigaddrspacetest
def
test_optimized_concat
(
self
):
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
with
self
.
assertRaises
(
OverflowError
)
as
cm
:
# this statement uses a fast path in ceval.c
x
=
x
+
b
"x"
*
128
with
self
.
assertRaises
(
OverflowError
)
as
cm
:
# this statement uses a fast path in ceval.c
x
+=
b
"x"
*
128
@bigaddrspacetest
def
test_repeat
(
self
):
x
=
b
"x"
*
(
MAX_Py_ssize_t
-
128
)
self
.
assertRaises
(
OverflowError
,
operator
.
mul
,
x
,
128
)
class
StrTest
(
unittest
.
TestCase
):
class
StrTest
(
unittest
.
TestCase
):
unicodesize
=
2
if
sys
.
maxunicode
<
65536
else
4
@bigaddrspacetest
@bigaddrspacetest
def
test_concat
(
self
):
def
test_concat
(
self
):
s1
=
'x'
*
MAX_Py_ssize_t
# Create a string half the size that would fill the address space
self
.
assertRaises
(
OverflowError
,
operator
.
add
,
s1
,
'?'
)
x
=
"x"
*
(
MAX_Py_ssize_t
//
(
2
*
self
.
unicodesize
))
# Unicode objects trigger MemoryError in case an operation that's
# going to cause a size overflow is executed
self
.
assertRaises
(
MemoryError
,
operator
.
add
,
x
,
x
)
@bigaddrspacetest
@bigaddrspacetest
def
test_optimized_concat
(
self
):
def
test_optimized_concat
(
self
):
x
=
'x'
*
MAX_Py_ssize_t
x
=
"x"
*
(
MAX_Py_ssize_t
//
(
2
*
self
.
unicodesize
))
try
:
x
=
x
+
'?'
# this statement uses a fast path in ceval.c
with
self
.
assertRaises
(
MemoryError
)
as
cm
:
except
OverflowError
:
# this statement uses a fast path in ceval.c
pass
x
=
x
+
x
else
:
self
.
fail
(
"should have raised OverflowError"
)
with
self
.
assertRaises
(
MemoryError
)
as
cm
:
try
:
# this statement uses a fast path in ceval.c
x
+=
'?'
# this statement uses a fast path in ceval.c
x
+=
x
except
OverflowError
:
pass
@bigaddrspacetest
else
:
def
test_repeat
(
self
):
self
.
fail
(
"should have raised OverflowError"
)
x
=
"x"
*
(
MAX_Py_ssize_t
//
(
2
*
self
.
unicodesize
))
self
.
assertEquals
(
len
(
x
),
MAX_Py_ssize_t
)
self
.
assertRaises
(
MemoryError
,
operator
.
mul
,
x
,
2
)
### the following test is pending a patch
# (http://mail.python.org/pipermail/python-dev/2006-July/067774.html)
#@bigaddrspacetest
#def test_repeat(self):
# self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1)
def
test_main
():
def
test_main
():
support
.
run_unittest
(
StrTest
)
support
.
run_unittest
(
BytesTest
,
StrTest
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
1
:
...
...
Misc/NEWS
Dosyayı görüntüle @
99c4830d
...
@@ -265,6 +265,9 @@ Tools/Demos
...
@@ -265,6 +265,9 @@ Tools/Demos
Tests
Tests
-----
-----
- Issue #3699: Fix test_bigaddrspace and extend it to test bytestrings
as well as unicode strings. Initial patch by Sandro Tosi.
- Issue #10294: Remove dead code form test_unicode_file.
- Issue #10294: Remove dead code form test_unicode_file.
- Issue #10123: Don't use non-ascii filenames in test_doctest tests. Add a
- Issue #10123: Don't use non-ascii filenames in test_doctest tests. Add a
...
...
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