patrol wrote: > On 7月17日, 上午12时16分, Tim Golden <[EMAIL PROTECTED]> wrote: >> Assuming that the error comes back in the sys.stdout encoding, the following >> version *should* work ok. I still haven't got a non-English set up to test >> it on, but it certainly does return a Unicode error message. >> >> http://timgolden.me.uk/wmi-project/wmi.py >> >> The usual test case, if you wouldn't mind: >> >> <code> >> import wmi >> >> wmi.WMI ("non-existent computer") >> >> </code> >> >> should give a (language-specific) error message, not an UnicodeDecodeError >> >> TJG > -------------------------------------------------------------------------------------- >>>> import wmi >>>> wmi.WMI('non-existent computer') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "C:\Python25\lib\wmi.py", line 1199, in connect > handle_com_error (error_info) > File "C:\Python25\lib\wmi.py", line 184, in handle_com_error > exception_string = [u"%s - %s" % (hex (hresult_code), > hresult_name)] > UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position > 4: ordinal > not in range(128) > -------------------------------------------------------------------------------------- > yup,error_info contains the Chinese encoded string. All of the Simple > Chinese Windows use the CP936.Every Chinese word utilizes two > bytes.Maybe you can fix this bug by modifying handle_com_error.
Can you confirm that that last bit of code was run with the version of wmi.py currently at: http://timgolden.me.uk/wmi-project/wmi.py That version should already be decoding the string correctly. TJG -- http://mail.python.org/mailman/listinfo/python-list