comparison Python/pythonrun.c @ 50460:636a0ac9607b legacy-trunk

Issue #4075: Use OutputDebugStringW in Py_FatalError.
author Martin v. Löwis <martin@v.loewis.de>
date Fri, 02 Jan 2009 20:32:55 +0000
parents 5d9be65e7891
children 68c9f8b6584d
comparison
equal deleted inserted replaced
50459:8eddd665e9b9 50460:636a0ac9607b
19 #include "marshal.h" 19 #include "marshal.h"
20 20
21 #ifdef HAVE_SIGNAL_H 21 #ifdef HAVE_SIGNAL_H
22 #include <signal.h> 22 #include <signal.h>
23 #endif 23 #endif
24
25 #include "malloc.h" /* for alloca */
24 26
25 #ifdef HAVE_LANGINFO_H 27 #ifdef HAVE_LANGINFO_H
26 #include <locale.h> 28 #include <locale.h>
27 #include <langinfo.h> 29 #include <langinfo.h>
28 #endif 30 #endif
1626 void 1628 void
1627 Py_FatalError(const char *msg) 1629 Py_FatalError(const char *msg)
1628 { 1630 {
1629 fprintf(stderr, "Fatal Python error: %s\n", msg); 1631 fprintf(stderr, "Fatal Python error: %s\n", msg);
1630 #ifdef MS_WINDOWS 1632 #ifdef MS_WINDOWS
1631 OutputDebugString("Fatal Python error: "); 1633 {
1632 OutputDebugString(msg); 1634 size_t len = strlen(msg);
1633 OutputDebugString("\n"); 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 }
1634 #ifdef _DEBUG 1648 #ifdef _DEBUG
1635 DebugBreak(); 1649 DebugBreak();
1636 #endif 1650 #endif
1637 #endif /* MS_WINDOWS */ 1651 #endif /* MS_WINDOWS */
1638 abort(); 1652 abort();