GeezerVison is showing github.com — Issue #4075: Use OutputDebugStringW in Py_FatalError. · yahalit/python@40fb890
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Misc/NEWS +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1 |
12 | 12 | Core and Builtins |
13 | 13 | ----------------- |
14 | 14 |
|
| 15 | +- Issue #4075: Use OutputDebugStringW in Py_FatalError. |
| 16 | + |
15 | 17 | - Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open |
16 | 18 | file with `str' filename on Windows. |
17 | 19 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: Python/pythonrun.c +17-3Lines changed: 17 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
22 | 22 | #include <signal.h> |
23 | 23 | #endif |
24 | 24 |
|
| 25 | +#include "malloc.h" /* for alloca */ |
| 26 | + |
25 | 27 | #ifdef HAVE_LANGINFO_H |
26 | 28 | #include <locale.h> |
27 | 29 | #include <langinfo.h> |
@@ -1628,9 +1630,21 @@ Py_FatalError(const char *msg) |
1628 | 1630 | { |
1629 | 1631 | fprintf(stderr, "Fatal Python error: %s\n", msg); |
1630 | 1632 | #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 | + } |
1634 | 1648 | #ifdef _DEBUG |
1635 | 1649 | DebugBreak(); |
1636 | 1650 | #endif |
|