]> granicus.if.org Git - python/commitdiff
Issue #4075: Use OutputDebugStringW in Py_FatalError.
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 2 Jan 2009 20:32:55 +0000 (20:32 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 2 Jan 2009 20:32:55 +0000 (20:32 +0000)
Misc/NEWS
Python/pythonrun.c

index af502b6cafe67316a659f331bb022ccb470513b0..6fed1bc680798041a32e2f79d8a44f4f0c150a3a 100644 (file)
--- 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.
 
index 54f3c5784bd86b1384e07ad4214890a971111a2d..0497ae6b0f14d1c385bf3c1b085d5179a7e62429 100644 (file)
@@ -22,6 +22,8 @@
 #include <signal.h>
 #endif
 
+#include "malloc.h" /* for alloca */
+
 #ifdef HAVE_LANGINFO_H
 #include <locale.h>
 #include <langinfo.h>
@@ -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