pyuno: uno.Char is UTF-16 code unit, not UCS-4

Check for that in ctor.

Change-Id: Ia69b3d87ac4ccb5b6cc13169d7022c04607c609f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108803
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
Michael Stahl 2021-01-05 13:30:26 +01:00
parent 33b8f7c10b
commit c7568cfdec

View File

@ -225,9 +225,9 @@ class Char:
Use an instance of this class to explicitly pass a char to UNO.
For Python 2, this class only works with unicode objects. Creating
a Char instance with a normal str object or comparing a Char instance
to a normal str object will raise an AssertionError.
For Python 3, this class only works with unicode (str) objects. Creating
a Char instance with a bytes object or comparing a Char instance
to a bytes object will raise an AssertionError.
:param value: A Unicode string with length 1
"""
@ -236,6 +236,7 @@ class Char:
assert isinstance(value, str), "Expected str object, got %s instead." % type(value)
assert len(value) == 1, "Char value must have length of 1."
assert ord(value[0]) <= 0xFFFF, "Char value must be UTF-16 code unit"
self.value = value