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
1c748f38
Kaydet (Commit)
1c748f38
authored
Eyl 07, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #27570: Merge null pointer fixes from 3.5
üst
f3b5bcaf
be8da9c9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
15 deletions
+40
-15
test_array.py
Lib/test/test_array.py
+12
-2
NEWS
Misc/NEWS
+3
-0
_ctypes.c
Modules/_ctypes/_ctypes.c
+4
-2
stgdict.c
Modules/_ctypes/stgdict.c
+5
-3
arraymodule.c
Modules/arraymodule.c
+16
-8
No files found.
Lib/test/test_array.py
Dosyayı görüntüle @
1c748f38
...
...
@@ -36,14 +36,24 @@ typecodes = "ubBhHiIlLfd"
if
have_long_long
:
typecodes
+=
'qQ'
class
BadConstructor
Test
(
unittest
.
TestCase
):
class
Misc
Test
(
unittest
.
TestCase
):
def
test_constructor
(
self
):
def
test_
bad_
constructor
(
self
):
self
.
assertRaises
(
TypeError
,
array
.
array
)
self
.
assertRaises
(
TypeError
,
array
.
array
,
spam
=
42
)
self
.
assertRaises
(
TypeError
,
array
.
array
,
'xx'
)
self
.
assertRaises
(
ValueError
,
array
.
array
,
'x'
)
def
test_empty
(
self
):
# Exercise code for handling zero-length arrays
a
=
array
.
array
(
'B'
)
a
[:]
=
a
self
.
assertEqual
(
len
(
a
),
0
)
self
.
assertEqual
(
len
(
a
+
a
),
0
)
self
.
assertEqual
(
len
(
a
*
3
),
0
)
a
+=
a
self
.
assertEqual
(
len
(
a
),
0
)
# Machine format codes.
#
...
...
Misc/NEWS
Dosyayı görüntüle @
1c748f38
...
...
@@ -96,6 +96,9 @@ Core and Builtins
Library
-------
-
Issue
#
27570
:
Avoid
zero
-
length
memcpy
()
etc
calls
with
null
source
pointers
in
the
"ctypes"
and
"array"
modules
.
-
Issue
#
22233
:
Break
email
header
lines
*
only
*
on
the
RFC
specified
CR
and
LF
characters
,
not
on
arbitrary
unicode
line
breaks
.
This
also
fixes
a
bug
in
HTTP
header
parsing
.
...
...
Modules/_ctypes/_ctypes.c
Dosyayı görüntüle @
1c748f38
...
...
@@ -1375,8 +1375,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
goto
error
;
}
stgdict
->
shape
[
0
]
=
length
;
memmove
(
&
stgdict
->
shape
[
1
],
itemdict
->
shape
,
sizeof
(
Py_ssize_t
)
*
(
stgdict
->
ndim
-
1
));
if
(
stgdict
->
ndim
>
1
)
{
memmove
(
&
stgdict
->
shape
[
1
],
itemdict
->
shape
,
sizeof
(
Py_ssize_t
)
*
(
stgdict
->
ndim
-
1
));
}
itemsize
=
itemdict
->
size
;
if
(
length
*
itemsize
<
0
)
{
...
...
Modules/_ctypes/stgdict.c
Dosyayı görüntüle @
1c748f38
...
...
@@ -391,9 +391,11 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
}
memset
(
stgdict
->
ffi_type_pointer
.
elements
,
0
,
sizeof
(
ffi_type
*
)
*
(
basedict
->
length
+
len
+
1
));
memcpy
(
stgdict
->
ffi_type_pointer
.
elements
,
basedict
->
ffi_type_pointer
.
elements
,
sizeof
(
ffi_type
*
)
*
(
basedict
->
length
));
if
(
basedict
->
length
>
0
)
{
memcpy
(
stgdict
->
ffi_type_pointer
.
elements
,
basedict
->
ffi_type_pointer
.
elements
,
sizeof
(
ffi_type
*
)
*
(
basedict
->
length
));
}
ffi_ofs
=
basedict
->
length
;
}
else
{
offset
=
0
;
...
...
Modules/arraymodule.c
Dosyayı görüntüle @
1c748f38
...
...
@@ -740,8 +740,10 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
np
=
(
arrayobject
*
)
newarrayobject
(
&
Arraytype
,
ihigh
-
ilow
,
a
->
ob_descr
);
if
(
np
==
NULL
)
return
NULL
;
memcpy
(
np
->
ob_item
,
a
->
ob_item
+
ilow
*
a
->
ob_descr
->
itemsize
,
(
ihigh
-
ilow
)
*
a
->
ob_descr
->
itemsize
);
if
(
ihigh
>
ilow
)
{
memcpy
(
np
->
ob_item
,
a
->
ob_item
+
ilow
*
a
->
ob_descr
->
itemsize
,
(
ihigh
-
ilow
)
*
a
->
ob_descr
->
itemsize
);
}
return
(
PyObject
*
)
np
;
}
...
...
@@ -799,9 +801,13 @@ array_concat(arrayobject *a, PyObject *bb)
if
(
np
==
NULL
)
{
return
NULL
;
}
memcpy
(
np
->
ob_item
,
a
->
ob_item
,
Py_SIZE
(
a
)
*
a
->
ob_descr
->
itemsize
);
memcpy
(
np
->
ob_item
+
Py_SIZE
(
a
)
*
a
->
ob_descr
->
itemsize
,
b
->
ob_item
,
Py_SIZE
(
b
)
*
b
->
ob_descr
->
itemsize
);
if
(
Py_SIZE
(
a
)
>
0
)
{
memcpy
(
np
->
ob_item
,
a
->
ob_item
,
Py_SIZE
(
a
)
*
a
->
ob_descr
->
itemsize
);
}
if
(
Py_SIZE
(
b
)
>
0
)
{
memcpy
(
np
->
ob_item
+
Py_SIZE
(
a
)
*
a
->
ob_descr
->
itemsize
,
b
->
ob_item
,
Py_SIZE
(
b
)
*
b
->
ob_descr
->
itemsize
);
}
return
(
PyObject
*
)
np
;
#undef b
}
...
...
@@ -821,7 +827,7 @@ array_repeat(arrayobject *a, Py_ssize_t n)
np
=
(
arrayobject
*
)
newarrayobject
(
&
Arraytype
,
size
,
a
->
ob_descr
);
if
(
np
==
NULL
)
return
NULL
;
if
(
n
==
0
)
if
(
size
==
0
)
return
(
PyObject
*
)
np
;
oldbytes
=
Py_SIZE
(
a
)
*
a
->
ob_descr
->
itemsize
;
newbytes
=
oldbytes
*
n
;
...
...
@@ -942,8 +948,10 @@ array_do_extend(arrayobject *self, PyObject *bb)
size
=
oldsize
+
Py_SIZE
(
b
);
if
(
array_resize
(
self
,
size
)
==
-
1
)
return
-
1
;
memcpy
(
self
->
ob_item
+
oldsize
*
self
->
ob_descr
->
itemsize
,
b
->
ob_item
,
bbsize
*
b
->
ob_descr
->
itemsize
);
if
(
bbsize
>
0
)
{
memcpy
(
self
->
ob_item
+
oldsize
*
self
->
ob_descr
->
itemsize
,
b
->
ob_item
,
bbsize
*
b
->
ob_descr
->
itemsize
);
}
return
0
;
#undef b
...
...
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