[Python-checkins] r68270 - in python/branches/release30-maint: Misc/NEWS Python/pythonrun.c

georg.brandl python-checkins at python.org
Sun Jan 4 00:58:58 CET 2009


Author: georg.brandl
Date: Sun Jan  4 00:58:58 2009
New Revision: 68270

Log:
Merged revisions 68175 via svnmerge from 
svn+ssh://svn.python.org/python/branches/py3k

................
  r68175 | martin.v.loewis | 2009-01-02 21:47:48 +0100 (Fri, 02 Jan 2009) | 13 lines
  
  Merged revisions 68172-68173 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r68172 | martin.v.loewis | 2009-01-02 21:32:55 +0100 (Fr, 02 Jan 2009) | 2 lines
    
    Issue #4075: Use OutputDebugStringW in Py_FatalError.
  ........
    r68173 | martin.v.loewis | 2009-01-02 21:40:14 +0100 (Fr, 02 Jan 2009) | 2 lines
    
    Issue #4051: Prevent conflict of UNICODE macros in cPickle.
  ........
................


Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Misc/NEWS
   python/branches/release30-maint/Python/pythonrun.c

Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS	(original)
+++ python/branches/release30-maint/Misc/NEWS	Sun Jan  4 00:58:58 2009
@@ -20,6 +20,8 @@
   print elapsed times, not only when some objects are uncollectable /
   unreachable. Original patch by Neil Schemenauer.
 
+- Issue #4075: Use OutputDebugStringW in Py_FatalError.
+
 - Issue #4747: When the terminal does not use utf-8, executing a script with
   non-ascii characters in its name could fail with a "SyntaxError: None" error.
 

Modified: python/branches/release30-maint/Python/pythonrun.c
==============================================================================
--- python/branches/release30-maint/Python/pythonrun.c	(original)
+++ python/branches/release30-maint/Python/pythonrun.c	Sun Jan  4 00:58:58 2009
@@ -23,6 +23,8 @@
 #include <signal.h>
 #endif
 
+#include "malloc.h" /* for alloca */
+
 #ifdef HAVE_LANGINFO_H
 #include <locale.h>
 #include <langinfo.h>
@@ -1918,9 +1920,21 @@
 		PyErr_Print();
 	}
 #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


More information about the Python-checkins mailing list