When Python.NET catches a form the CLR code, it tries a
conversion to a string. This conversion fails if the
exception message contains non-ASCII chars(>= 128).
This is particularly bad because with non-english
versions of the .NET framework the exception messages
are localized. (In german, many exception texts contain
"äöü", causing the described error)
Result:
- The user gets an error message of the form
"SomeDotNetExceptionType: <Unprintable exception message>"
- The "testStrOfException" unit test inside
"test_exceptions.py" fails.
Logged In: NO
To temporarily get the real exception reason, this
workaround may help:
from CLR.System import Exception
try:
doSthBad()
except Exception, e:
print e.ToString()
Logged In: NO
The failing unit test says:
======================================================================
ERROR: Test the str() representation of an exception.
----------------------------------------------------------------------
Traceback (most recent call last):
File "d:\Projekte\PythonNet\src\tests\test_exceptions.py",
line 308, in testStrOfException
self.failUnless(str(e).find('at System.DateTime.Parse')
> -1)
UnicodeEncodeError: 'ascii' codec can't encode character
u'\xfc' in position 34: ordinal not in range(128)
Logged In: NO
Comment '2006-11-02 01:37' seems to be wrong. Better method:
try:
doSthBad()
except Exception, e:
print e.ToString().encode('iso-8859-1', 'ignore')