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
7e4f3215
Kaydet (Commit)
7e4f3215
authored
Tem 05, 2009
tarafından
Alexandre Vassalotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 4509: Do not modify an array if we know the change would result
in a failure due to exported buffers.
üst
200cfd00
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
test_array.py
Lib/test/test_array.py
+16
-0
arraymodule.c
Modules/arraymodule.c
+8
-0
No files found.
Lib/test/test_array.py
Dosyayı görüntüle @
7e4f3215
...
@@ -749,9 +749,25 @@ class BaseTest(unittest.TestCase):
...
@@ -749,9 +749,25 @@ class BaseTest(unittest.TestCase):
ArraySubclassWithKwargs
(
'b'
,
newarg
=
1
)
ArraySubclassWithKwargs
(
'b'
,
newarg
=
1
)
def
test_create_from_bytes
(
self
):
def
test_create_from_bytes
(
self
):
# XXX This test probably needs to be moved in a subclass or
# generalized to use self.typecode.
a
=
array
.
array
(
'H'
,
b
"1234"
)
a
=
array
.
array
(
'H'
,
b
"1234"
)
self
.
assertEqual
(
len
(
a
)
*
a
.
itemsize
,
4
)
self
.
assertEqual
(
len
(
a
)
*
a
.
itemsize
,
4
)
def
test_memoryview_no_resize
(
self
):
# Test for issue 4509.
a
=
array
.
array
(
self
.
typecode
,
self
.
example
)
m
=
memoryview
(
a
)
expected
=
m
.
tobytes
()
self
.
assertRaises
(
BufferError
,
a
.
pop
,
0
)
self
.
assertEqual
(
m
.
tobytes
(),
expected
)
self
.
assertRaises
(
BufferError
,
a
.
remove
,
a
[
0
])
self
.
assertEqual
(
m
.
tobytes
(),
expected
)
self
.
assertRaises
(
BufferError
,
a
.
__setitem__
,
slice
(
0
,
0
),
a
)
self
.
assertEqual
(
m
.
tobytes
(),
expected
)
self
.
assertRaises
(
BufferError
,
a
.
__delitem__
,
slice
(
0
,
len
(
a
)))
self
.
assertEqual
(
m
.
tobytes
(),
expected
)
class
StringTest
(
BaseTest
):
class
StringTest
(
BaseTest
):
...
...
Modules/arraymodule.c
Dosyayı görüntüle @
7e4f3215
...
@@ -735,6 +735,14 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
...
@@ -735,6 +735,14 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
ihigh
=
Py_SIZE
(
a
);
ihigh
=
Py_SIZE
(
a
);
item
=
a
->
ob_item
;
item
=
a
->
ob_item
;
d
=
n
-
(
ihigh
-
ilow
);
d
=
n
-
(
ihigh
-
ilow
);
/* Issue #4509: If the array has exported buffers and the slice
assignment would change the size of the array, fail early to make
sure we don't modify it. */
if
(
d
!=
0
&&
a
->
ob_exports
>
0
)
{
PyErr_SetString
(
PyExc_BufferError
,
"cannot resize an array that is exporting buffers"
);
return
-
1
;
}
if
(
d
<
0
)
{
/* Delete -d items */
if
(
d
<
0
)
{
/* Delete -d items */
memmove
(
item
+
(
ihigh
+
d
)
*
a
->
ob_descr
->
itemsize
,
memmove
(
item
+
(
ihigh
+
d
)
*
a
->
ob_descr
->
itemsize
,
item
+
ihigh
*
a
->
ob_descr
->
itemsize
,
item
+
ihigh
*
a
->
ob_descr
->
itemsize
,
...
...
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