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
d518d8bc
Kaydet (Commit)
d518d8bc
authored
May 09, 2018
tarafından
Oren Milman
Kaydeden (comit)
Steve Dower
May 09, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-21983: Fix a crash in ctypes.cast() when passed a ctypes structured data type (GH-3859)
üst
8cf4b34b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
test_cast.py
Lib/ctypes/test/test_cast.py
+13
-0
2017-10-02-21-02-14.bpo-21983.UoC319.rst
...ore and Builtins/2017-10-02-21-02-14.bpo-21983.UoC319.rst
+2
-0
_ctypes.c
Modules/_ctypes/_ctypes.c
+1
-1
No files found.
Lib/ctypes/test/test_cast.py
Dosyayı görüntüle @
d518d8bc
...
@@ -82,5 +82,18 @@ class Test(unittest.TestCase):
...
@@ -82,5 +82,18 @@ class Test(unittest.TestCase):
self
.
assertEqual
(
cast
(
cast
(
s
,
c_void_p
),
c_wchar_p
)
.
value
,
self
.
assertEqual
(
cast
(
cast
(
s
,
c_void_p
),
c_wchar_p
)
.
value
,
"hiho"
)
"hiho"
)
def
test_bad_type_arg
(
self
):
# The type argument must be a ctypes pointer type.
array_type
=
c_byte
*
sizeof
(
c_int
)
array
=
array_type
()
self
.
assertRaises
(
TypeError
,
cast
,
array
,
None
)
self
.
assertRaises
(
TypeError
,
cast
,
array
,
array_type
)
class
Struct
(
Structure
):
_fields_
=
[(
"a"
,
c_int
)]
self
.
assertRaises
(
TypeError
,
cast
,
array
,
Struct
)
class
MyUnion
(
Union
):
_fields_
=
[(
"a"
,
c_int
)]
self
.
assertRaises
(
TypeError
,
cast
,
array
,
MyUnion
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
Misc/NEWS.d/next/Core and Builtins/2017-10-02-21-02-14.bpo-21983.UoC319.rst
0 → 100644
Dosyayı görüntüle @
d518d8bc
Fix a crash in `ctypes.cast()` in case the type argument is a ctypes
structured data type. Patch by Eryk Sun and Oren Milman.
Modules/_ctypes/_ctypes.c
Dosyayı görüntüle @
d518d8bc
...
@@ -5319,7 +5319,7 @@ cast_check_pointertype(PyObject *arg)
...
@@ -5319,7 +5319,7 @@ cast_check_pointertype(PyObject *arg)
if
(
PyCFuncPtrTypeObject_Check
(
arg
))
if
(
PyCFuncPtrTypeObject_Check
(
arg
))
return
1
;
return
1
;
dict
=
PyType_stgdict
(
arg
);
dict
=
PyType_stgdict
(
arg
);
if
(
dict
)
{
if
(
dict
!=
NULL
&&
dict
->
proto
!=
NULL
)
{
if
(
PyUnicode_Check
(
dict
->
proto
)
if
(
PyUnicode_Check
(
dict
->
proto
)
&&
(
strchr
(
"sPzUZXO"
,
PyUnicode_AsUTF8
(
dict
->
proto
)[
0
])))
{
&&
(
strchr
(
"sPzUZXO"
,
PyUnicode_AsUTF8
(
dict
->
proto
)[
0
])))
{
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
...
...
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