File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
1212Core 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments