/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/python/unicode_strings_runme.py
21 строка
774 B
Julien Schueller
Drop SWIG_PYTHON_2_UNICODE
07 июл 2026, 01:50
07 июл 2026, 01:50
8f0cbe1
Код
Авторство
О чём код?
import unicode_strings test_string = "h\udce9llo w\u00f6rld" if unicode_strings.non_utf8_c_str() != test_string: raise ValueError("Test comparison mismatch") if unicode_strings.non_utf8_std_string() != test_string: raise ValueError("Test comparison mismatch") def check(s1, s2): if s1 != s2: raise RuntimeError("{} != {}".format(s1, s2)) low_surrogate_string = "\udcff" try: unicode_strings.instring(low_surrogate_string) raise RuntimeError("Exception should have been thrown") except TypeError as e: # Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError. # The real error is actually: # UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed pass