Skip to content

Commit 40fb890

Browse files
author
martin.v.loewis
committed
Issue #4075: Use OutputDebugStringW in Py_FatalError.
git-svn-id: http://svn.python.org/projects/python/trunk@68172 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 7d2d3b6 commit 40fb890

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #4075: Use OutputDebugStringW in Py_FatalError.
16+
1517
- Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
1618
file with `str' filename on Windows.
1719

Python/pythonrun.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <signal.h>
2323
#endif
2424

25+
#include "malloc.h" /* for alloca */
26+
2527
#ifdef HAVE_LANGINFO_H
2628
#include <locale.h>
2729
#include <langinfo.h>
@@ -1628,9 +1630,21 @@ Py_FatalError(const char *msg)
16281630
{
16291631
fprintf(stderr, "Fatal Python error: %s\n", msg);
16301632
#ifdef MS_WINDOWS
1631-
OutputDebugString("Fatal Python error: ");
1632-
OutputDebugString(msg);
1633-
OutputDebugString("\n");
1633+
{
1634+
size_t len = strlen(msg);
1635+
WCHAR* buffer;
1636+
size_t i;
1637+
1638+
/* Convert the message to wchar_t. This uses a simple one-to-one
1639+
conversion, assuming that the this error message actually uses ASCII
1640+
only. If this ceases to be true, we will have to convert. */
1641+
buffer = alloca( (len+1) * (sizeof *buffer));
1642+
for( i=0; i<=len; ++i)
1643+
buffer[i] = msg[i];
1644+
OutputDebugStringW(L"Fatal Python error: ");
1645+
OutputDebugStringW(buffer);
1646+
OutputDebugStringW(L"\n");
1647+
}
16341648
#ifdef _DEBUG
16351649
DebugBreak();
16361650
#endif

0 commit comments

Comments
 (0)