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
9d062d69
Unverified
Kaydet (Commit)
9d062d69
authored
Nis 19, 2019
tarafından
Inada Naoki
Kaydeden (comit)
GitHub
Nis 19, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
ctypes: remove use of legacy unicode API (GH-12340)
PyUnicode_AsUnicodeAndSize() -> PyUnicode_AsWideChar()
üst
e8113f51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
_ctypes.c
Modules/_ctypes/_ctypes.c
+7
-7
cfield.c
Modules/_ctypes/cfield.c
+12
-8
No files found.
Modules/_ctypes/_ctypes.c
Dosyayı görüntüle @
9d062d69
...
...
@@ -1304,8 +1304,6 @@ static int
WCharArray_set_value
(
CDataObject
*
self
,
PyObject
*
value
,
void
*
Py_UNUSED
(
ignored
))
{
Py_ssize_t
result
=
0
;
Py_UNICODE
*
wstr
;
Py_ssize_t
len
;
if
(
value
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
...
...
@@ -1320,12 +1318,14 @@ WCharArray_set_value(CDataObject *self, PyObject *value, void *Py_UNUSED(ignored
}
else
Py_INCREF
(
value
);
wstr
=
PyUnicode_AsUnicodeAndSize
(
value
,
&
len
);
if
(
wstr
==
NULL
)
Py_ssize_t
len
=
PyUnicode_AsWideChar
(
value
,
NULL
,
0
);
if
(
len
<
0
)
{
return
-
1
;
if
((
size_t
)
len
>
self
->
b_size
/
sizeof
(
wchar_t
))
{
PyErr_SetString
(
PyExc_ValueError
,
"string too long"
);
}
// PyUnicode_AsWideChar() returns number of wchars including trailing null byte,
// when it is called with NULL.
if
(((
size_t
)
len
-
1
)
>
self
->
b_size
/
sizeof
(
wchar_t
))
{
PyErr_SetString
(
PyExc_ValueError
,
"string too long"
);
result
=
-
1
;
goto
done
;
}
...
...
Modules/_ctypes/cfield.c
Dosyayı görüntüle @
9d062d69
...
...
@@ -1229,9 +1229,6 @@ U_get(void *ptr, Py_ssize_t size)
static
PyObject
*
U_set
(
void
*
ptr
,
PyObject
*
value
,
Py_ssize_t
length
)
{
Py_UNICODE
*
wstr
;
Py_ssize_t
size
;
/* It's easier to calculate in characters than in bytes */
length
/=
sizeof
(
wchar_t
);
...
...
@@ -1242,9 +1239,14 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length)
return
NULL
;
}
wstr
=
PyUnicode_AsUnicodeAndSize
(
value
,
&
size
);
if
(
wstr
==
NULL
)
Py_ssize_t
size
=
PyUnicode_AsWideChar
(
value
,
NULL
,
0
);
if
(
size
<
0
)
{
return
NULL
;
}
// PyUnicode_AsWideChar() returns number of wchars including trailing null byte,
// when it is called with NULL.
size
--
;
assert
(
size
>=
0
);
if
(
size
>
length
)
{
PyErr_Format
(
PyExc_ValueError
,
"string too long (%zd, maximum length %zd)"
,
...
...
@@ -1421,16 +1423,18 @@ BSTR_set(void *ptr, PyObject *value, Py_ssize_t size)
/* create a BSTR from value */
if
(
value
)
{
wchar_t
*
wvalue
;
Py_ssize_t
wsize
;
w
value
=
PyUnicode_AsUnicodeAndSize
(
value
,
&
wsize
);
if
(
wvalue
==
NULL
)
w
char_t
*
wvalue
=
PyUnicode_AsWideCharString
(
value
,
&
wsize
);
if
(
wvalue
==
NULL
)
{
return
NULL
;
}
if
((
unsigned
)
wsize
!=
wsize
)
{
PyErr_SetString
(
PyExc_ValueError
,
"String too long for BSTR"
);
PyMem_Free
(
wvalue
);
return
NULL
;
}
bstr
=
SysAllocStringLen
(
wvalue
,
(
unsigned
)
wsize
);
PyMem_Free
(
wvalue
);
}
else
bstr
=
NULL
;
...
...
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