Don't restrict wrapped char to ASCII values
Previously, if a VTK methods returned a char
value that with an
extended (non-ASCII) value, the Python wrappers would raise an
exception:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0
Likewise, passing a Python str
of length 1 to a VTK method as a char
would give an error if the unicode value was >127
:
TypeError: InsertNextValue argument 1: a string of length 1 is required
The new code allows unicode values in the range [0,255]
to be passed and
returned with the Python wrappers. Also, the new code raises a ValueError
exception rather than a TypeError exception if the value is out of range.
Furthermore, previously a char value of '\0'
would be returned as ''
,
and calling ord('')
in Python raises a TypeError. This has been corrected
so that '\0'
is returned instead, and ord('\0')
is zero as expected.