About wmi

Tim Golden mail at timgolden.me.uk
Wed Jul 16 13:45:03 EDT 2008


patrol wrote:
>>>> 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.


Well, that's what I've done in that latest version.
Only I naively assumed
that I could use sys.stdout.encoding to determine
the encoding. I'll have to try harder.

TJG



More information about the Python-list mailing list