blob: 78dee1893f47d8cd9b95978b603be8bbe76d5a35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
"""
emoji-string-test.py
This is the original code from the bug report
https://bugreports.qt.io/browse/PYSIDE-336
The only changes are the emoji constant creation which avoids unicode in the
source itself, utf8 encoding in line 1 and a short plausibility test to make
it safely fail.
"""
import os
import sys
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
from init_paths import init_test_paths
init_test_paths()
from PySide6.QtCore import QObject, Signal
emoji_str = u'\U0001f632' + u' ' # "😲 "
class TestStuff(QObject):
testsig = Signal(str)
def a_nop(self, sendMeAnEmoji):
print(sendMeAnEmoji)
return
def __init__(self):
super().__init__()
self.testsig.connect(self.a_nop)
self.testsig.emit(emoji_str)
def plausi(self):
# Python 2 may be built with UCS-2 or UCS-4 support.
# UCS-2 creates 2 surrogate code points. See
# https://stackoverflow.com/questions/30775689/python-length-of-unicode-string-confusion
assert len(emoji_str) == 2 if sys.maxunicode > 0xffff else 3
if __name__ == "__main__":
mything = TestStuff()
mything.plausi()
|