From 5344c99734af01d11c2eca19f308640c5035dd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 2 Jan 2009 20:32:55 +0000 Subject: Issue #4075: Use OutputDebugStringW in Py_FatalError. --- Misc/NEWS | 2 ++ Python/pythonrun.c | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index af502b6..6fed1bc 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1 Core and Builtins ----------------- +- Issue #4075: Use OutputDebugStringW in Py_FatalError. + - Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open file with `str' filename on Windows. diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 54f3c57..0497ae6 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -22,6 +22,8 @@ #include #endif +#include "malloc.h" /* for alloca */ + #ifdef HAVE_LANGINFO_H #include #include @@ -1628,9 +1630,21 @@ Py_FatalError(const char *msg) { fprintf(stderr, "Fatal Python error: %s\n", msg); #ifdef MS_WINDOWS - OutputDebugString("Fatal Python error: "); - OutputDebugString(msg); - OutputDebugString("\n"); + { + size_t len = strlen(msg); + 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 DebugBreak(); #endif -- cgit v0.12