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
71fb5134
Kaydet (Commit)
71fb5134
authored
Kas 26, 2008
tarafından
Thomas Heller
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Prevent UnicodeDecodeErrors in ctypes with non-ascii error messages.
Fixes issue #4429. Reviewed by Amaury Forgeot d'Arc.
üst
d951e7b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
29 deletions
+18
-29
NEWS
Misc/NEWS
+2
-0
callproc.c
Modules/_ctypes/callproc.c
+16
-29
No files found.
Misc/NEWS
Dosyayı görüntüle @
71fb5134
...
...
@@ -22,6 +22,8 @@ Core and Builtins
Library
-------
- Issue #4429: Fixed UnicodeDecodeError in ctypes.
- Issue #4373: Corrected a potential reference leak in the pickle module and
silenced a false positive ref leak in distutils.tests.test_build_ext.
...
...
Modules/_ctypes/callproc.c
Dosyayı görüntüle @
71fb5134
...
...
@@ -209,21 +209,21 @@ set_last_error(PyObject *self, PyObject *args)
PyObject
*
ComError
;
static
T
CHAR
*
FormatError
(
DWORD
code
)
static
W
CHAR
*
FormatError
(
DWORD
code
)
{
T
CHAR
*
lpMsgBuf
;
W
CHAR
*
lpMsgBuf
;
DWORD
n
;
n
=
FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
code
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
// Default language
(
LPT
STR
)
&
lpMsgBuf
,
0
,
NULL
);
n
=
FormatMessage
W
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
,
NULL
,
code
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
// Default language
(
LPW
STR
)
&
lpMsgBuf
,
0
,
NULL
);
if
(
n
)
{
while
(
_ist
space
(
lpMsgBuf
[
n
-
1
]))
while
(
isw
space
(
lpMsgBuf
[
n
-
1
]))
--
n
;
lpMsgBuf
[
n
]
=
_T
(
'\0'
)
;
/* rstrip() */
lpMsgBuf
[
n
]
=
L'\0'
;
/* rstrip() */
}
return
lpMsgBuf
;
}
...
...
@@ -231,7 +231,7 @@ static TCHAR *FormatError(DWORD code)
#ifndef DONT_USE_SEH
void
SetException
(
DWORD
code
,
EXCEPTION_RECORD
*
pr
)
{
T
CHAR
*
lpMsgBuf
;
W
CHAR
*
lpMsgBuf
;
lpMsgBuf
=
FormatError
(
code
);
if
(
lpMsgBuf
)
{
PyErr_SetFromWindowsErr
(
code
);
...
...
@@ -972,7 +972,7 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk)
DWORD
helpcontext
=
0
;
LPOLESTR
progid
;
PyObject
*
obj
;
TCHAR
*
text
;
LPOLESTR
text
;
/* We absolutely have to release the GIL during COM method calls,
otherwise we may get a deadlock!
...
...
@@ -1012,11 +1012,7 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk)
text
=
FormatError
(
errcode
);
obj
=
Py_BuildValue
(
#ifdef _UNICODE
"iu(uuuiu)"
,
#else
"is(uuuiu)"
,
#endif
errcode
,
text
,
descr
,
source
,
helpfile
,
helpcontext
,
...
...
@@ -1202,15 +1198,6 @@ _parse_voidp(PyObject *obj, void **address)
#ifdef MS_WIN32
#ifdef _UNICODE
# define PYBUILD_TSTR "u"
#else
# define PYBUILD_TSTR "s"
# ifndef _T
# define _T(text) text
# endif
#endif
static
char
format_error_doc
[]
=
"FormatError([integer]) -> string
\n
\
\n
\
...
...
@@ -1219,7 +1206,7 @@ given, the return value of a call to GetLastError() is used.\n";
static
PyObject
*
format_error
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
result
;
TCHAR
*
lpMsgBuf
;
wchar_t
*
lpMsgBuf
;
DWORD
code
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"|i:FormatError"
,
&
code
))
return
NULL
;
...
...
@@ -1227,10 +1214,10 @@ static PyObject *format_error(PyObject *self, PyObject *args)
code
=
GetLastError
();
lpMsgBuf
=
FormatError
(
code
);
if
(
lpMsgBuf
)
{
result
=
Py
_BuildValue
(
PYBUILD_TSTR
,
lpMsgBuf
);
result
=
Py
Unicode_FromWideChar
(
lpMsgBuf
,
wcslen
(
lpMsgBuf
)
);
LocalFree
(
lpMsgBuf
);
}
else
{
result
=
Py
_BuildValue
(
"s"
,
"<no description>"
);
result
=
Py
Unicode_FromString
(
"<no description>"
);
}
return
result
;
}
...
...
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