There's a thread over on c.l.py which concerns the error messages returned from the WMI module, which
uses win32com.client and all its works and promises...

http://mail.python.org/pipermail/python-list/2008-July/499172.html

The OP is running on a Simple Chinese edition of Windows XP,
and the error message, naturally, returns Simple Chinese
characters. But... it's apparent that the com_error info
structure returns not Unicode but byte stream. I *think*
I can decode into Unicode by using the sys.stdout.encoding,
but even if I'm right that's a fragile solution: running
under the SciTE editor, eg, sys.stdout.encoding is None.

So, a couple of questions:

1) Is there some API which will tell me: non-Unicode error
messages can be converted to Unicode *thus*. I've looked
around, but there's nothing too obvious.

2) How onerous would it be to change PyCom_BuildPyException
to call FormatMessageW and to return true Unicode objects?
Non-trivial, I imagine, since that function's called everywhere,
but maybe now's the time...?

[... three questions; nobody expects ...]

3) Is there something more obvious which I've missed?

An alternative which occurs to me is to call FormatMessageW
myself from my own code, given the hresult, but I'd rather
that were a workaround rather than a solution.

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to