summaryrefslogtreecommitdiff
path: root/pyuno/source
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-01-05 13:30:26 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-01-06 17:37:29 +0100
commitc7568cfdec8ababa4d73eddb7bed057404a6a009 (patch)
treed92d5eac5273ee76812e720b85a54e20dc721b63 /pyuno/source
parent33b8f7c10baead5fdd24d9b68caab54052bd00ba (diff)
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>
Diffstat (limited to 'pyuno/source')
-rw-r--r--pyuno/source/module/uno.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/pyuno/source/module/uno.py b/pyuno/source/module/uno.py
index c4ca808feaa0..5fa7b135736d 100644
--- a/pyuno/source/module/uno.py
+++ b/pyuno/source/module/uno.py
@@ -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