mirror of https://github.com/python/cpython
Issue #5078: Avoid redundant call to FormatError()
This commit is contained in:
parent
208b00d03f
commit
e09f161618
|
@ -234,14 +234,12 @@ static TCHAR *FormatError(DWORD code)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DONT_USE_SEH
|
#ifndef DONT_USE_SEH
|
||||||
void SetException(DWORD code, EXCEPTION_RECORD *pr)
|
static void SetException(DWORD code, EXCEPTION_RECORD *pr)
|
||||||
{
|
{
|
||||||
TCHAR *lpMsgBuf;
|
/* The 'code' is a normal win32 error code so it could be handled by
|
||||||
lpMsgBuf = FormatError(code);
|
PyErr_SetFromWindowsErr(). However, for some errors, we have additional
|
||||||
if(lpMsgBuf) {
|
information not included in the error code. We handle those here and
|
||||||
PyErr_SetFromWindowsErr(code);
|
delegate all others to the generic function. */
|
||||||
LocalFree(lpMsgBuf);
|
|
||||||
} else {
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
/* The thread attempted to read from or write
|
/* The thread attempted to read from or write
|
||||||
|
@ -256,6 +254,7 @@ void SetException(DWORD code, EXCEPTION_RECORD *pr)
|
||||||
"exception: access violation writing %p",
|
"exception: access violation writing %p",
|
||||||
pr->ExceptionInformation[1]);
|
pr->ExceptionInformation[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXCEPTION_BREAKPOINT:
|
case EXCEPTION_BREAKPOINT:
|
||||||
/* A breakpoint was encountered. */
|
/* A breakpoint was encountered. */
|
||||||
PyErr_SetString(PyExc_WindowsError,
|
PyErr_SetString(PyExc_WindowsError,
|
||||||
|
@ -375,15 +374,12 @@ void SetException(DWORD code, EXCEPTION_RECORD *pr)
|
||||||
PyErr_SetString(PyExc_WindowsError,
|
PyErr_SetString(PyExc_WindowsError,
|
||||||
"exception: nocontinuable");
|
"exception: nocontinuable");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("error %d\n", code);
|
PyErr_SetFromWindowsErr(code);
|
||||||
PyErr_Format(PyExc_WindowsError,
|
|
||||||
"exception code 0x%08x",
|
|
||||||
code);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD HandleException(EXCEPTION_POINTERS *ptrs,
|
static DWORD HandleException(EXCEPTION_POINTERS *ptrs,
|
||||||
DWORD *pdw, EXCEPTION_RECORD *record)
|
DWORD *pdw, EXCEPTION_RECORD *record)
|
||||||
|
|
Loading…
Reference in New Issue