Issue #4075: Use OutputDebugStringW in Py_FatalError.

This commit is contained in:
Martin v. Löwis 2009-01-02 20:32:55 +00:00
parent fc29f27c16
commit 5344c99734
2 changed files with 19 additions and 3 deletions

View file

@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #4075: Use OutputDebugStringW in Py_FatalError.
- Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open - Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
file with `str' filename on Windows. file with `str' filename on Windows.

View file

@ -22,6 +22,8 @@
#include <signal.h> #include <signal.h>
#endif #endif
#include "malloc.h" /* for alloca */
#ifdef HAVE_LANGINFO_H #ifdef HAVE_LANGINFO_H
#include <locale.h> #include <locale.h>
#include <langinfo.h> #include <langinfo.h>
@ -1628,9 +1630,21 @@ Py_FatalError(const char *msg)
{ {
fprintf(stderr, "Fatal Python error: %s\n", msg); fprintf(stderr, "Fatal Python error: %s\n", msg);
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
OutputDebugString("Fatal Python error: "); {
OutputDebugString(msg); size_t len = strlen(msg);
OutputDebugString("\n"); WCHAR* buffer;
size_t i;
/* Convert the message to wchar_t. This uses a simple one-to-one
conversion, assuming that the this error message actually uses ASCII
only. If this ceases to be true, we will have to convert. */
buffer = alloca( (len+1) * (sizeof *buffer));
for( i=0; i<=len; ++i)
buffer[i] = msg[i];
OutputDebugStringW(L"Fatal Python error: ");
OutputDebugStringW(buffer);
OutputDebugStringW(L"\n");
}
#ifdef _DEBUG #ifdef _DEBUG
DebugBreak(); DebugBreak();
#endif #endif