From 21b683f455f906cc8ef789610d84f7027617d5d6 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Tue, 8 Apr 2025 08:47:41 +0100 Subject: [PATCH 1/4] Upgrade syntax to Python 3 --- bench/py_functioncalls.py | 10 ++--- bench/support.py | 3 +- python/cppyy/__init__.py | 14 +++--- python/cppyy/_cpython_cppyy.py | 6 +-- python/cppyy/_pythonization.py | 20 ++++----- python/cppyy/interactive.py | 2 +- python/cppyy/ll.py | 4 +- python/cppyy/numba_ext.py | 12 ++--- python/cppyy_compat/__init__.py | 4 +- test/bindexplib.py | 2 - test/datatypes.cxx | 28 ++++++------ test/datatypes.h | 4 +- test/make_dict_win32.py | 4 +- test/support.py | 3 +- test/test_advancedcpp.py | 4 +- test/test_concurrent.py | 2 +- test/test_crossinheritance.py | 48 ++++++++++---------- test/test_datatypes.py | 78 ++++++++++++++++----------------- test/test_doc_features.py | 10 ++--- test/test_lowlevel.py | 2 +- test/test_pythonify.py | 2 +- test/test_regression.py | 12 ++--- test/test_stltypes.py | 27 +++++------- 23 files changed, 147 insertions(+), 154 deletions(-) diff --git a/bench/py_functioncalls.py b/bench/py_functioncalls.py index c25a827d..3c23c899 100644 --- a/bench/py_functioncalls.py +++ b/bench/py_functioncalls.py @@ -6,13 +6,13 @@ def empty_call(): pass #- group: empty-inst --------------------------------------------------------- -class EmptyCall(object): +class EmptyCall: def empty_call(self): pass #- group: builtin-args-free -------------------------------------------------- -class Value(object): +class Value: def __init__(self): self.m_int = 42 @@ -26,7 +26,7 @@ def take_a_struct(val): pass #- group: builtin-args-inst -------------------------------------------------- -class TakeAValue(object): +class TakeAValue: def take_an_int(self, val): pass @@ -45,12 +45,12 @@ def do_work(val): return math.atan(val) #- group: do_work-inst ------------------------------------------------------- -class DoWork(object): +class DoWork: def do_work(self, val): return math.atan(val) #- group: overload-inst ------------------------------------------------------ -class OverloadedCall(object): +class OverloadedCall: def add_it(self, *args): return 3.1415 + sum(args) diff --git a/bench/support.py b/bench/support.py index a2eeeaf2..48d4ab86 100644 --- a/bench/support.py +++ b/bench/support.py @@ -1,4 +1,3 @@ -from __future__ import print_function import py, sys, subprocess currpath = py.path.local(__file__).dirpath() @@ -11,4 +10,4 @@ def setup_make(targetname): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, _ = popen.communicate() if popen.returncode: - raise OSError("'make' failed:\n%s" % (stdout,)) + raise OSError("'make' failed:\n{}".format(stdout)) diff --git a/python/cppyy/__init__.py b/python/cppyy/__init__.py index dc00b0d6..a674b866 100644 --- a/python/cppyy/__init__.py +++ b/python/cppyy/__init__.py @@ -152,7 +152,7 @@ def __ne__(self, other): # std::make_shared/unique create needless templates: rely on Python's introspection # instead. This also allows Python derived classes to be handled correctly. -class py_make_smartptr(object): +class py_make_smartptr: __slots__ = ['cls', 'ptrcls'] def __init__(self, cls, ptrcls): self.cls = cls @@ -164,7 +164,7 @@ def __call__(self, *args): obj = self.cls(*args) return self.ptrcls[self.cls](obj) # C++ takes ownership -class make_smartptr(object): +class make_smartptr: __slots__ = ['ptrcls', 'maker'] def __init__(self, ptrcls, maker): self.ptrcls = ptrcls @@ -187,7 +187,7 @@ def __getitem__(self, cls): #--- interface to Cling ------------------------------------------------------ -class _stderr_capture(object): +class _stderr_capture: def __init__(self): self._capture = not gbl.Cpp.IsDebugOutputEnabled() self.err = "" @@ -240,7 +240,7 @@ def load_library(name): CppInterOp = gbl.Cpp result = CppInterOp.LoadLibrary(name) if result == False: - raise RuntimeError('Could not load library "%s": %s' % (name, err.err)) + raise RuntimeError('Could not load library "{}": {}'.format(name, err.err)) return True @@ -249,7 +249,7 @@ def include(header): with _stderr_capture() as err: errcode = gbl.Cpp.Declare('#include "%s"' % header) if not errcode == 0: - raise ImportError('Failed to load header file "%s"%s' % (header, err.err)) + raise ImportError('Failed to load header file "{}"{}'.format(header, err.err)) return True def c_include(header): @@ -259,7 +259,7 @@ def c_include(header): #include "%s" }""" % header) if not errcode == 0: - raise ImportError('Failed to load header file "%s"%s' % (header, err.err)) + raise ImportError('Failed to load header file "{}"{}'.format(header, err.err)) return True def add_include_path(path): @@ -389,7 +389,7 @@ def sizeof(tt): try: sz = ctypes.sizeof(tt) except TypeError: - sz = gbl.Cpp.Evaluate("sizeof(%s)" % (_get_name(tt),)) + sz = gbl.Cpp.Evaluate("sizeof({})".format(_get_name(tt))) _sizes[tt] = sz return sz diff --git a/python/cppyy/_cpython_cppyy.py b/python/cppyy/_cpython_cppyy.py index c26a86c4..639564d9 100644 --- a/python/cppyy/_cpython_cppyy.py +++ b/python/cppyy/_cpython_cppyy.py @@ -54,7 +54,7 @@ def ismethod(object): ### template support --------------------------------------------------------- -class Template(object): # expected/used by ProxyWrappers.cxx in CPyCppyy +class Template: # expected/used by ProxyWrappers.cxx in CPyCppyy stl_sequence_types = ['std::vector', 'std::list', 'std::set', 'std::deque'] stl_unrolled_types = ['std::pair'] stl_fixed_size_types = ['std::array'] @@ -67,7 +67,7 @@ def __init__(self, name, scope): self.__scope__ = scope def __repr__(self): - return "" % (self.__name__, hex(id(self))) + return "".format(self.__name__, hex(id(self))) def __getitem__(self, *args): # multi-argument to [] becomes a single tuple argument @@ -177,7 +177,7 @@ def add_default_paths(): f = line.strip() if (os.path.exists(f)): libCppInterOp.AddSearchPath(f) - except IOError: + except OSError: pass add_default_paths() del add_default_paths diff --git a/python/cppyy/_pythonization.py b/python/cppyy/_pythonization.py index d49b90f8..fb1aa200 100644 --- a/python/cppyy/_pythonization.py +++ b/python/cppyy/_pythonization.py @@ -59,20 +59,20 @@ def set_ownership_policy(match_class, match_method, python_owns_result): # NB: Ideally, we'd use the version commented out below, but for now, we # make do with the hackier version here. def rename_attribute(match_class, orig_attribute, new_attribute, keep_orig=False): - class attribute_pythonizor(object): - class getter(object): + class attribute_pythonizor: + class getter: def __init__(self, attr): self.attr = attr def __call__(self, obj): return getattr(obj, self.attr) - class setter(object): + class setter: def __init__(self, attr): self.attr = attr def __call__(self, obj, value): return setattr(obj, self.attr, value) - class deleter(object): + class deleter: def __init__(self, attr): self.attr = attr def __call__(self, obj): @@ -123,7 +123,7 @@ def __call__(self, obj, name): # Shared with PyPy: def add_overload(match_class, match_method, overload): - class method_pythonizor(object): + class method_pythonizor: def __init__(self, match_class, match_method, overload): import re self.match_class = re.compile(match_class) @@ -146,7 +146,7 @@ def __call__(self, obj, name): def compose_method(match_class, match_method, g): - class composition_pythonizor(object): + class composition_pythonizor: def __init__(self, match_class, match_method, g): import re self.match_class = re.compile(match_class) @@ -174,7 +174,7 @@ def h(self, *args, **kwargs): def set_method_property(match_class, match_method, prop, value): - class method_pythonizor(object): + class method_pythonizor: def __init__(self, match_class, match_method, prop, value): import re self.match_class = re.compile(match_class) @@ -196,7 +196,7 @@ def __call__(self, obj, name): def make_property(match_class, match_get, match_set=None, match_del=None, prop_name=None): - class property_pythonizor(object): + class property_pythonizor: def __init__(self, match_class, match_get, match_set, match_del, prop_name): import re self.match_class = re.compile(match_class) @@ -230,7 +230,7 @@ def __init__(self, match_class, match_get, match_set, match_del, prop_name): self.prop_name = prop_name def make_get_del_proxy(self, getter): - class proxy(object): + class proxy: def __init__(self, getter): self.getter = getter @@ -239,7 +239,7 @@ def __call__(self, obj): return proxy(getter) def make_set_proxy(self, setter): - class proxy(object): + class proxy: def __init__(self, setter): self.setter = setter diff --git a/python/cppyy/interactive.py b/python/cppyy/interactive.py index a9be6c3e..019a4090 100644 --- a/python/cppyy/interactive.py +++ b/python/cppyy/interactive.py @@ -8,7 +8,7 @@ #- fake namespace for interactive lazy lookups ------------------------------- -class InteractiveLazy(object): +class InteractiveLazy: def __init__(self, hook_okay): self._hook_okay = hook_okay diff --git a/python/cppyy/ll.py b/python/cppyy/ll.py index 7a8493a7..02f76431 100644 --- a/python/cppyy/ll.py +++ b/python/cppyy/ll.py @@ -46,7 +46,7 @@ def argc(): # import low-level python converters for _name in ['addressof', 'as_cobject', 'as_capsule', 'as_ctypes']: try: - exec('%s = cppyy._backend.%s' % (_name, _name)) + exec('{} = cppyy._backend.{}'.format(_name, _name)) __all__.append(_name) except AttributeError: pass @@ -81,7 +81,7 @@ def argc(): # helper for sizing arrays -class ArraySizer(object): +class ArraySizer: def __init__(self, func): self.func = func def __getitem__(self, t): diff --git a/python/cppyy/numba_ext.py b/python/cppyy/numba_ext.py index da860027..421a7bf2 100644 --- a/python/cppyy/numba_ext.py +++ b/python/cppyy/numba_ext.py @@ -112,7 +112,7 @@ class CppFunctionNumbaType(nb_types.Callable): requires_gil = False def __init__(self, func, is_method=False): - super(CppFunctionNumbaType, self).__init__('CppFunction(%s)' % str(func)) + super().__init__('CppFunction(%s)' % str(func)) self.sig = None self._func = func @@ -195,7 +195,7 @@ def __init__(self, dmm, fe_type): # the function pointer of this overload can not be exactly typed, but # only the storage size is relevant, so simply use a void* be_type = ir.PointerType(dmm.lookup(nb_types.void).get_value_type()) - super(CppFunctionModel, self).__init__(dmm, fe_type, be_type) + super().__init__(dmm, fe_type, be_type) @nb_iutils.lower_constant(CppFunctionNumbaType) def constant_function_pointer(context, builder, ty, pyval): @@ -207,7 +207,7 @@ def constant_function_pointer(context, builder, ty, pyval): # # C++ method / data member -> Numba # -class CppDataMemberInfo(object): +class CppDataMemberInfo: __slots__ = ['f_name', 'f_offset', 'f_nbtype', 'f_irtype'] def __init__(self, name, offset, cpptype): @@ -222,7 +222,7 @@ def __init__(self, name, offset, cpptype): # class CppClassNumbaType(CppFunctionNumbaType): def __init__(self, scope, qualifier): - super(CppClassNumbaType, self).__init__(scope.__init__) + super().__init__(scope.__init__) self.name = 'CppClass(%s)' % scope.__cpp_name__ # overrides value in Type self._scope = scope self._qualifier = qualifier @@ -234,7 +234,7 @@ def get_qualifier(self): return self._qualifier def get_call_type(self, context, args, kwds): - sig = super(CppClassNumbaType, self).get_call_type(context, args, kwds) + sig = super().get_call_type(context, args, kwds) self.sig = sig return sig @@ -428,7 +428,7 @@ def get_value_type(self): # TODO: this doesn't work for real PODs, b/c those are unpacked into their elements and # passed through registers - return ir.PointerType(super(ImplClassModel, self).get_value_type()) + return ir.PointerType(super().get_value_type()) # argument: representation used for function argument. Needs to be builtin type, # but unlike other Numba composites, C++ proxies are not flattened. diff --git a/python/cppyy_compat/__init__.py b/python/cppyy_compat/__init__.py index d9d36055..b805921d 100644 --- a/python/cppyy_compat/__init__.py +++ b/python/cppyy_compat/__init__.py @@ -15,7 +15,7 @@ def pypy58_57_compat(): os.chdir(os.path.dirname(c._name)) imp.init_builtin('cppyy') except ImportError: - raise EnvironmentError('"%s" missing in LD_LIBRARY_PATH' %\ + raise OSError('"%s" missing in LD_LIBRARY_PATH' %\ os.path.dirname(c._name)) finally: os.chdir(olddir) @@ -52,7 +52,7 @@ def py59_compat(): actual_name = __name__; __name__ = '' import _cppyy as _backend except ImportError: - raise EnvironmentError('"%s" missing in LD_LIBRARY_PATH' % os.path.dirname(c._name)) + raise OSError('"%s" missing in LD_LIBRARY_PATH' % os.path.dirname(c._name)) finally: __name__ = actual_name os.chdir(olddir) diff --git a/test/bindexplib.py b/test/bindexplib.py index 838dca4d..fc8754a8 100755 --- a/test/bindexplib.py +++ b/test/bindexplib.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import os, sys, subprocess target = sys.argv[1] diff --git a/test/datatypes.cxx b/test/datatypes.cxx index 31641c3c..2e54d38e 100644 --- a/test/datatypes.cxx +++ b/test/datatypes.cxx @@ -13,8 +13,8 @@ CppyyTestData::CppyyTestData() : m_const_int(17), m_owns_arrays(false) m_schar = 'b'; m_uchar = 'c'; m_wchar = L'D'; - m_char16 = u'\u00df'; - m_char32 = U'\u00df'; + m_char16 = '\u00df'; + m_char32 = '\u00df'; #if __cplusplus > 201402L m_byte = (std::byte)'d'; #endif @@ -336,8 +336,8 @@ void CppyyTestData::set_enum_cr(const EWhat& w) { m_enum = void CppyyTestData::set_bool_r(bool& b) { b = true; } void CppyyTestData::set_char_r(char& c) { c = 'a'; } void CppyyTestData::set_wchar_r(wchar_t& wc) { wc = 'b'; } -void CppyyTestData::set_char16_r(char16_t& c16) { c16 = u'\u6c24'; } -void CppyyTestData::set_char32_r(char32_t& c32) { c32 = U'\U0001f34e'; } +void CppyyTestData::set_char16_r(char16_t& c16) { c16 = '\u6c24'; } +void CppyyTestData::set_char32_r(char32_t& c32) { c32 = '\U0001f34e'; } void CppyyTestData::set_schar_r(signed char& sc) { sc = 'c'; } void CppyyTestData::set_uchar_r(unsigned char& uc) { uc = 'd'; } #if __cplusplus > 201402L @@ -359,8 +359,8 @@ void CppyyTestData::set_ldouble_r(long double& ld) { ld = 10.l; } void CppyyTestData::set_bool_p(bool* b) { *b = true; } void CppyyTestData::set_char_p(char* c) { *c = 'a'; } void CppyyTestData::set_wchar_p(wchar_t* wc) { *wc = 'b'; } -void CppyyTestData::set_char16_p(char16_t* c16) { *c16 = u'\u6c24'; } -void CppyyTestData::set_char32_p(char32_t* c32) { *c32 = U'\U0001f34e'; } +void CppyyTestData::set_char16_p(char16_t* c16) { *c16 = '\u6c24'; } +void CppyyTestData::set_char32_p(char32_t* c32) { *c32 = '\U0001f34e'; } void CppyyTestData::set_schar_p(signed char* sc) { *sc = 'c'; } void CppyyTestData::set_uchar_p(unsigned char* uc) { *uc = 'd'; } #if __cplusplus > 201402L @@ -393,11 +393,11 @@ void CppyyTestData::set_wchar_ppa(wchar_t** wc) { } void CppyyTestData::set_char16_ppa(char16_t** c16) { (*c16) = new char16_t[3]; - (*c16)[0] = u'\u6c24'; (*c16)[1] = u'\u6c25'; (*c16)[2] = u'\u6c26'; + (*c16)[0] = '\u6c24'; (*c16)[1] = '\u6c25'; (*c16)[2] = '\u6c26'; } void CppyyTestData::set_char32_ppa(char32_t** c32) { (*c32) = new char32_t[3]; - (*c32)[0] = U'\U0001f34d'; (*c32)[1] = U'\U0001f34e'; (*c32)[2] = U'\U0001f34f'; + (*c32)[0] = '\U0001f34d'; (*c32)[1] = '\U0001f34e'; (*c32)[2] = '\U0001f34f'; } void CppyyTestData::set_schar_ppa(signed char** sc) { (*sc) = new signed char[3]; @@ -551,8 +551,8 @@ char CppyyTestData::s_char = 'c'; signed char CppyyTestData::s_schar = 's'; unsigned char CppyyTestData::s_uchar = 'u'; wchar_t CppyyTestData::s_wchar = L'U'; -char16_t CppyyTestData::s_char16 = u'\u6c29'; -char32_t CppyyTestData::s_char32 = U'\U0001f34b'; +char16_t CppyyTestData::s_char16 = '\u6c29'; +char32_t CppyyTestData::s_char32 = '\U0001f34b'; #if __cplusplus > 201402L std::byte CppyyTestData::s_byte = (std::byte)'b'; #endif @@ -613,8 +613,8 @@ char g_char = 'w'; signed char g_schar = 'v'; unsigned char g_uchar = 'u'; wchar_t g_wchar = L'U'; -char16_t g_char16 = u'\u6c21'; -char32_t g_char32 = U'\u6c21'; +char16_t g_char16 = '\u6c21'; +char32_t g_char32 = '\u6c21'; #if __cplusplus > 201402L std::byte g_byte = (std::byte)'x'; #endif @@ -672,8 +672,8 @@ std::string get_some_global_string() { return g_some_global_string; } std::string g_some_global_string2 = "C++"; std::string get_some_global_string2() { return g_some_global_string2; } -const char16_t* g_some_global_string16 = u"z\u00df\u6c34"; -const char32_t* g_some_global_string32 = U"z\u00df\u6c34\U0001f34c"; +const char16_t* g_some_global_string16 = "z\u00df\u6c34"; +const char32_t* g_some_global_string32 = "z\u00df\u6c34\U0001f34c"; std::string SomeStaticDataNS::s_some_static_string = "C++"; std::string SomeStaticDataNS::get_some_static_string() { return s_some_static_string; } diff --git a/test/datatypes.h b/test/datatypes.h index 8a2d5d51..5f4ec1f9 100644 --- a/test/datatypes.h +++ b/test/datatypes.h @@ -608,8 +608,8 @@ static const char g_c_char = 'z'; static const signed char g_c_schar = 'y'; static const unsigned char g_c_uchar = 'x'; static const wchar_t g_c_wchar = L'U'; -static const char16_t g_c_char16 = u'\u6c34'; -static const char32_t g_c_char32 = U'\U0001f34c'; +static const char16_t g_c_char16 = '\u6c34'; +static const char32_t g_c_char32 = '\U0001f34c'; #if __cplusplus > 201402L static const std::byte g_c_byte = (std::byte)'u'; #endif diff --git a/test/make_dict_win32.py b/test/make_dict_win32.py index 6837f6b0..ef5f35b4 100755 --- a/test/make_dict_win32.py +++ b/test/make_dict_win32.py @@ -1,6 +1,6 @@ import glob, os, sys, subprocess -USES_PYTHON_CAPI = set(('pythonizables',)) +USES_PYTHON_CAPI = {'pythonizables'} fn = sys.argv[1] @@ -15,7 +15,7 @@ if fn[-4:] == '.cxx': fn = fn[:-4] elif fn[-2:] == '.h': fn = fn[:-2] if not os.path.exists(fn+'.h'): - print("file %s.h does not exist" % (fn,)) + print("file {}.h does not exist".format(fn)) sys.exit(1) uses_python_capi = False diff --git a/test/support.py b/test/support.py index b69ca309..d27e4d25 100644 --- a/test/support.py +++ b/test/support.py @@ -1,4 +1,3 @@ -from __future__ import print_function import os, py, sys, subprocess currpath = py.path.local(__file__).dirpath() @@ -13,7 +12,7 @@ def setup_make(targetname): stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout, _ = popen.communicate() if popen.returncode: - raise OSError("'make' failed:\n%s" % (stdout,)) + raise OSError("'make' failed:\n{}".format(stdout)) if sys.hexversion >= 0x3000000: pylong = int diff --git a/test/test_advancedcpp.py b/test/test_advancedcpp.py index 623452da..554b4b36 100644 --- a/test/test_advancedcpp.py +++ b/test/test_advancedcpp.py @@ -623,9 +623,9 @@ def test16_template_global_functions(self): f = cppyy.gbl.my_templated_function assert f('c') == 'c' - assert type(f('c')) == type('c') + assert type(f('c')) == str assert f(3.) == 3. - assert type(f(4.)) == type(4.) + assert type(f(4.)) == float def test17_assign_to_return_byref(self): """Test assignment to an instance returned by reference""" diff --git a/test/test_concurrent.py b/test/test_concurrent.py index 5d74d0cd..e7fc4a39 100644 --- a/test/test_concurrent.py +++ b/test/test_concurrent.py @@ -281,7 +281,7 @@ class Simulation2 { cppyy.gbl.CPPOverloadReuse.Simulation2.do_something.__release_gil__ = True - class State(object): + class State: lock = threading.Lock() c1, c2, c3 = 0, 0, 0 diff --git a/test/test_crossinheritance.py b/test/test_crossinheritance.py index 9bab6994..a5291c23 100644 --- a/test/test_crossinheritance.py +++ b/test/test_crossinheritance.py @@ -82,7 +82,7 @@ def test03_override_function_abstract_base(self): class C1PyBase2(CX.IBase2): def __init__(self): - super(C1PyBase2, self).__init__() + super().__init__() def get_value(self): return 99 @@ -96,11 +96,11 @@ def get_value(self): class C3PyBase2(CX.CBase2): def __init__(self): - super(C3PyBase2, self).__init__() + super().__init__() class C4PyBase2(CX.CBase2): def __init__(self): - super(C4PyBase2, self).__init__() + super().__init__() def get_value(self): return 13 @@ -121,7 +121,7 @@ def get_value(self): # now with abstract constructor that takes an argument class C4PyBase2(CX.IBase3): def __init__(self, intval): - super(C4PyBase2, self).__init__(intval) + super().__init__(intval) def get_value(self): return 77 @@ -196,14 +196,14 @@ def test06_const_methods(self): class C1PyBase4(CX.IBase4): def __init__(self): - super(C1PyBase4, self).__init__() + super().__init__() def get_value(self): return 17 class C2PyBase4(CX.CBase4): def __init__(self): - super(C2PyBase4, self).__init__() + super().__init__() c1, c2 = C1PyBase4(), C2PyBase4() @@ -365,7 +365,7 @@ class Abstract { class PyDerived(Abstract): def __init__(self, val): - super(PyDerived, self).__init__() + super().__init__() self.val = val def some_imp(self): return self.val @@ -500,7 +500,7 @@ class MyPyDerived(ns.MyBase): class MyPyDerived(ns.MyBase): def __init__(self): - super(MyPyDerived, self).__init__() + super().__init__() assert self.my_data == 101 self.py_data = 13 self.my_data = 42 @@ -690,7 +690,7 @@ class Base { class PyDerived1(ns.Base): def __init__(self): - super(PyDerived1, self).__init__() + super().__init__() self._name = "PyDerived1" def whoami(self): @@ -698,7 +698,7 @@ def whoami(self): class PyDerived2(PyDerived1): def __init__(self): - super(PyDerived2, self).__init__() + super().__init__() self._message = "Hello, World!" def message(self): @@ -872,7 +872,7 @@ class MyClass3 { class MyPyDerived(cppyy.multi(ns.MyClass1, ns.MyClass2)): def __init__(self, val1, val2): - super(MyPyDerived, self).__init__((val1,), (val2,)) + super().__init__((val1,), (val2,)) def x(self): return 16 @@ -891,7 +891,7 @@ def y(self): class MyPyDerived2(cppyy.multi(ns.MyClass1, ns.MyClass2, ns.MyClass3)): def __init__(self, val1, val2, val3): - super(MyPyDerived2, self).__init__((val1,), (val2,), (val3,)) + super().__init__((val1,), (val2,), (val3,)) def x(self): return 16 @@ -961,13 +961,13 @@ def __init__(self, val1=None, val2=None, val3=None, nArgs=3): a2 = val2 is not None and (val2,) or () a3 = val3 is not None and (val3,) or () if nArgs == 3: - super(MyPyDerived, self).__init__(a1, a2, a3) + super().__init__(a1, a2, a3) elif nArgs == 0: - super(MyPyDerived, self).__init__() + super().__init__() elif nArgs == 1: - super(MyPyDerived, self).__init__(a1) + super().__init__(a1) elif nArgs == 2: - super(MyPyDerived, self).__init__(a1, a2) + super().__init__(a1, a2) def x(self): return 16 @@ -1104,7 +1104,7 @@ class DerivedMulti(cppyy.multi(Movable, Copyable)): # used to fail with compilation error class DerivedNoCopyNoMove(NoCopyNoMove): def __init__(self): - super(DerivedNoCopyNoMove, self).__init__(self) + super().__init__(self) # TODO: chicken-and-egg situation here, 'this' from 'self' is # nullptr until the constructor has been called, so it can't # be passed as an argument to the same constructor @@ -1150,7 +1150,7 @@ def test25_default_ctor_and_multiple_inheritance(self): class DerivedMulti(cppyy.multi(Movable, Copyable, SomeClass)): def __init__(self): - super(DerivedMulti, self).__init__() + super().__init__() d = DerivedMulti() assert d @@ -1184,7 +1184,7 @@ class Simple {}; }""") for kls in (ns.NoDefCtor1, ns.NoDefCtor2, ns.NoDefCtor3): class PyDerived(kls): def __init__(self): - super(PyDerived, self).__init__() + super().__init__() with raises(TypeError): PyDerived() @@ -1192,7 +1192,7 @@ def __init__(self): with warnings.catch_warnings(record=True) as w: class PyDerived(cppyy.multi(kls, ns.Simple)): def __init__(self): - super(PyDerived, self).__init__() + super().__init__() with raises(TypeError): PyDerived() @@ -1200,7 +1200,7 @@ def __init__(self): with warnings.catch_warnings(record=True) as w: class PyDerived(cppyy.multi(ns.Simple, kls)): def __init__(self): - super(PyDerived, self).__init__() + super().__init__() with raises(TypeError): PyDerived() @@ -1269,7 +1269,7 @@ class A { class B(A): def __init__ (self, name = 'b'): - super(B, self).__init__(name) + super().__init__(name) def fun1(self): return 1 @@ -1353,7 +1353,7 @@ def calc_b(self): assert ns.calc_a(g) == 20 assert ns.calc_b(g) == 45 - class H(object): + class H: def calc_a(self): return 66 @@ -1482,7 +1482,7 @@ def getValue(self): ns.ComponentWithValue.__init__.__creates__ = True class PyComponentWithInit(ns.ComponentWithValue): def __init__(self, cppvalue): - super(PyComponentWithInit, self).__init__(cppvalue) + super().__init__(cppvalue) self.m_pyvalue = 11 def getValue(self): diff --git a/test/test_datatypes.py b/test/test_datatypes.py index 3315d9a8..67c09558 100644 --- a/test/test_datatypes.py +++ b/test/test_datatypes.py @@ -39,11 +39,11 @@ def test01_instance_data_read_access(self): assert c.m_schar == 'b' assert c.m_uchar == 'c' assert type(c.m_wchar) == pyunicode - assert c.m_wchar == u'D' + assert c.m_wchar == 'D' assert type(c.m_char16) == pyunicode - assert c.m_char16 == u'\u00df' + assert c.m_char16 == '\u00df' assert type(c.m_char32) == pyunicode - assert c.m_char32 == u'\u00df' + assert c.m_char32 == '\u00df' # reading integer types assert c.m_int8 == - 9; assert c.get_int8_cr() == - 9; assert c.get_int8_r() == - 9 @@ -216,10 +216,10 @@ def test02_instance_data_write_access(self): # char types through functions c.set_char('c'); assert c.get_char() == 'c' c.set_uchar('e'); assert c.get_uchar() == 'e' - c.set_wchar(u'F'); assert c.get_wchar() == u'F' + c.set_wchar('F'); assert c.get_wchar() == 'F' assert type(c.get_wchar()) == pyunicode - c.set_char16(u'\u00f2'); assert c.get_char16() == u'\u00f2' - c.set_char32(u'\U0001f31c'); assert c.get_char32() == u'\U0001f31c' + c.set_char16('\u00f2'); assert c.get_char16() == '\u00f2' + c.set_char32('\U0001f31c'); assert c.get_char32() == '\U0001f31c' # char types through data members c.m_char = 'b'; assert c.get_char() == 'b' @@ -230,12 +230,12 @@ def test02_instance_data_write_access(self): c.m_uchar = 42; assert c.get_uchar() == chr(42) c.set_uchar('e'); assert c.m_uchar == 'e' c.set_uchar(43); assert c.m_uchar == chr(43) - c.m_wchar = u'G'; assert c.get_wchar() == u'G' - c.set_wchar(u'H'); assert c.m_wchar == u'H' - c.m_char16 = u'\u00f3'; assert c.get_char16() == u'\u00f3' - c.set_char16(u'\u00f4'); assert c.m_char16 == u'\u00f4' - c.m_char32 = u'\U0001f31d'; assert c.get_char32() == u'\U0001f31d' - c.set_char32(u'\U0001f31e'); assert c.m_char32 == u'\U0001f31e' + c.m_wchar = 'G'; assert c.get_wchar() == 'G' + c.set_wchar('H'); assert c.m_wchar == 'H' + c.m_char16 = '\u00f3'; assert c.get_char16() == '\u00f3' + c.set_char16('\u00f4'); assert c.m_char16 == '\u00f4' + c.m_char32 = '\U0001f31d'; assert c.get_char32() == '\U0001f31d' + c.set_char32('\U0001f31e'); assert c.m_char32 == '\U0001f31e' raises(ValueError, c.set_char, "string") raises(ValueError, c.set_char, 500) @@ -391,12 +391,12 @@ def test04_class_read_access(self): assert c.s_char == 'c' assert CppyyTestData.s_uchar == 'u' assert c.s_uchar == 'u' - assert CppyyTestData.s_wchar == u'U' - assert c.s_wchar == u'U' - assert CppyyTestData.s_char16 == u'\u6c29' - assert c.s_char16 == u'\u6c29' - assert CppyyTestData.s_char32 == u'\U0001f34b' - assert c.s_char32 == u'\U0001f34b' + assert CppyyTestData.s_wchar == 'U' + assert c.s_wchar == 'U' + assert CppyyTestData.s_char16 == '\u6c29' + assert c.s_char16 == '\u6c29' + assert CppyyTestData.s_char32 == '\U0001f34b' + assert c.s_char32 == '\U0001f34b' assert type(c.s_wchar) == pyunicode assert type(CppyyTestData.s_wchar) == pyunicode @@ -460,18 +460,18 @@ def test05_class_data_write_access(self): assert CppyyTestData.s_uchar == 'd' raises(ValueError, setattr, CppyyTestData, 's_uchar', -1) raises(ValueError, setattr, c, 's_uchar', -1) - CppyyTestData.s_wchar = u'K' - assert c.s_wchar == u'K' - c.s_wchar = u'L' - assert CppyyTestData.s_wchar == u'L' - CppyyTestData.s_char16 = u'\u00df' - assert c.s_char16 == u'\u00df' - c.s_char16 = u'\u00ef' - assert CppyyTestData.s_char16 == u'\u00ef' - CppyyTestData.s_char32 = u'\u00df' - assert c.s_char32 == u'\u00df' - c.s_char32 = u'\u00ef' - assert CppyyTestData.s_char32 == u'\u00ef' + CppyyTestData.s_wchar = 'K' + assert c.s_wchar == 'K' + c.s_wchar = 'L' + assert CppyyTestData.s_wchar == 'L' + CppyyTestData.s_char16 = '\u00df' + assert c.s_char16 == '\u00df' + c.s_char16 = '\u00ef' + assert CppyyTestData.s_char16 == '\u00ef' + CppyyTestData.s_char32 = '\u00df' + assert c.s_char32 == '\u00df' + c.s_char32 = '\u00ef' + assert CppyyTestData.s_char32 == '\u00ef' # integer types if self.has_byte: @@ -600,8 +600,8 @@ def test08_global_builtin_type(self): gbl.g_some_global_string2 = "Python" assert gbl.get_some_global_string2() == "Python" - assert gbl.g_some_global_string16 == u'z\u00df\u6c34' - assert gbl.g_some_global_string32 == u'z\u00df\u6c34\U0001f34c' + assert gbl.g_some_global_string16 == 'z\u00df\u6c34' + assert gbl.g_some_global_string32 == 'z\u00df\u6c34\U0001f34c' NS = gbl.SomeStaticDataNS NS.s_some_static_string = "Python" @@ -843,14 +843,14 @@ def test13_string_passing(self): assert c.get_valid_string('aap') == 'aap' assert c.get_invalid_string() == '' - assert c.get_valid_wstring(u'aap') == u'aap' - assert c.get_invalid_wstring() == u'' + assert c.get_valid_wstring('aap') == 'aap' + assert c.get_invalid_wstring() == '' - assert c.get_valid_string16(u'z\u00df\u6c34') == u'z\u00df\u6c34' - assert c.get_invalid_string16() == u'' + assert c.get_valid_string16('z\u00df\u6c34') == 'z\u00df\u6c34' + assert c.get_invalid_string16() == '' - assert c.get_valid_string32(u'z\u00df\u6c34\U0001f34c') == u'z\u00df\u6c34\U0001f34c' - assert c.get_invalid_string32() == u'' + assert c.get_valid_string32('z\u00df\u6c34\U0001f34c') == 'z\u00df\u6c34\U0001f34c' + assert c.get_invalid_string32() == '' def test14_copy_constructor(self): """Test copy constructor""" @@ -1500,7 +1500,7 @@ class Base { class Derived(ns.Base): def __init__(self): - super(Derived, self).__init__() + super().__init__() self.execute = self.xyz def xyz(self): diff --git a/test/test_doc_features.py b/test/test_doc_features.py index bdecdf3e..3e241d72 100644 --- a/test/test_doc_features.py +++ b/test/test_doc_features.py @@ -413,7 +413,7 @@ def concrete_method(self): class PyConcrete3(Abstract): def __init__(self): - super(PyConcrete3, self).__init__() + super().__init__() def abstract_method(self): return "Hello, Python World! (3)" @@ -426,7 +426,7 @@ def concrete_method(self): class PyConcrete4(Concrete): def __init__(self): - super(PyConcrete4, self).__init__() + super().__init__() def abstract_method(self): return "Hello, Python World! (4)" @@ -1136,7 +1136,7 @@ def test_cross_and_templates(self): class PyMyClass(CC.MyClass): def __init__(self, data, extra): - super(PyMyClass, self).__init__(data) + super().__init__(data) self.extra = extra def add(self, i): @@ -1295,8 +1295,8 @@ def test_unicode(self): return to_str(chars); }}""") - assert CC.gbk_chinese() == u'\u4e2d\u6587'.encode('gbk') + assert CC.gbk_chinese() == '\u4e2d\u6587'.encode('gbk') if 0x3000000 <= sys.hexversion: - assert CC.utf8_chinese() == u'\u4e2d\u6587' + assert CC.utf8_chinese() == '\u4e2d\u6587' else: assert CC.utf8_chinese() == b'\xe4\xb8\xad\xe6\x96\x87' diff --git a/test/test_lowlevel.py b/test/test_lowlevel.py index 18443b0b..4e22a6e6 100644 --- a/test/test_lowlevel.py +++ b/test/test_lowlevel.py @@ -177,7 +177,7 @@ def test06_ctypes_as_ref_and_ptr(self): # char types if e == '_r': c = ctypes.c_char(b'\0'); getattr(ctd, 'set_char'+e)(c); assert c.value == b'a' - c = ctypes.c_wchar(u'\0'); getattr(ctd, 'set_wchar'+e)(c); assert c.value == u'b' + c = ctypes.c_wchar('\0'); getattr(ctd, 'set_wchar'+e)(c); assert c.value == 'b' c = ctypes.c_byte(0); getattr(ctd, 'set_schar'+e)(c); assert c.value == ord('c') c = ctypes.c_ubyte(0); getattr(ctd, 'set_uchar'+e)(c); assert c.value == ord('d') diff --git a/test/test_pythonify.py b/test/test_pythonify.py index 725c43e4..9ad00ddd 100644 --- a/test/test_pythonify.py +++ b/test/test_pythonify.py @@ -64,7 +64,7 @@ def test03_calling_static_functions(self): res = example01_class.staticStrcpy("aap") # TODO: this leaks assert res == "aap" - res = example01_class.staticStrcpy(u"aap") # TODO: id. + res = example01_class.staticStrcpy("aap") # TODO: id. assert res == "aap" raises(TypeError, example01_class.staticStrcpy, 1.) # TODO: id. diff --git a/test/test_regression.py b/test/test_regression.py index a58b3791..573aa51f 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -108,7 +108,7 @@ def test04_avx(self): has_avx = False try: - f = open('/proc/cpuinfo', 'r') + f = open('/proc/cpuinfo') for line in f.readlines(): if 'avx' in line: has_avx = True @@ -1113,13 +1113,13 @@ def test38_char16_arrays(self): ns = cppyy.gbl.Char16Fixed ai = ns.AxisInformation() - for s in [u'hello', u'hellow']: + for s in ['hello', 'hellow']: ai.name = s len(ai.name) == 6 assert ai.name[:len(s)] == s with warnings.catch_warnings(record=True) as w: - ai.name = u'hellowd' + ai.name = 'hellowd' assert 'too long' in str(w[-1].message) # vector of objects @@ -1127,21 +1127,21 @@ def test38_char16_arrays(self): ns.fillem(va.data(), N) for ai in va: assert len(ai.name) == 6 - assert ai.name[:5] == u'hello' + assert ai.name[:5] == 'hello' # array of objects aa = cppyy.gbl.std.array[ns.AxisInformation, N]() ns.fillem(aa.data(), N) for ai in aa: assert len(ai.name) == 6 - assert ai.name[:5] == u'hello' + assert ai.name[:5] == 'hello' # low-level array of objects aa = cppyy.ll.array_new[ns.AxisInformation](N) ns.fillem(aa, N) for ai in aa: assert len(ai.name) == 6 - assert ai.name[:5] == u'hello' + assert ai.name[:5] == 'hello' cppyy.ll.array_delete(aa) @mark.xfail(run=False, reason="Crashes with Clang-Repl with assert in CodeGen::CodeGenFunction::EmitAggExpr") diff --git a/test/test_stltypes.py b/test/test_stltypes.py index 8bad09be..be467476 100644 --- a/test/test_stltypes.py +++ b/test/test_stltypes.py @@ -1,4 +1,3 @@ -# -*- coding: UTF-8 -*- import py, os, sys from pytest import raises, skip, mark from .support import setup_make, pylong, pyunicode, maxvalue, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC @@ -13,8 +12,7 @@ def setup_module(mod): # after CPython's Lib/test/seq_tests.py def iterfunc(seqn): """Regular generator""" - for i in seqn: - yield i + yield from seqn class Sequence: """Sequence using __getitem__""" @@ -43,8 +41,7 @@ def __init__(self, seqn): self.seqn = seqn self.i = 0 def __iter__(self): - for val in self.seqn: - yield val + yield from self.seqn class IterNextOnly: """Missing __getitem__ and __iter__""" @@ -807,7 +804,7 @@ def test03_string_with_null_character(self): assert std.string('ab\0c') == 'ab\0c' assert repr(std.string('ab\0c')) == repr(b'ab\0c') - assert str(std.string('ab\0c')) == str('ab\0c') + assert str(std.string('ab\0c')) == 'ab\0c' @mark.xfail(condition=IS_MAC, run=False, reason="Fails on OS X") def test04_array_of_strings(self): @@ -845,7 +842,7 @@ def test05_stlstring_and_unicode(self): uas = cppyy.gbl.UnicodeAndSTL - actlen = len(u'ℕ'.encode(encoding='UTF-8')) + actlen = len('ℕ'.encode(encoding='UTF-8')) assert uas.get_size('ℕ') == actlen assert uas.get_size_cr('ℕ') == actlen assert uas.get_size_cc('ℕ') == actlen @@ -864,7 +861,7 @@ def test05_stlstring_and_unicode(self): assert uas.get_string_w('ℕ').encode(encoding='UTF-8') == 'ℕ' assert uas.get_string_wcr('ℕ').encode(encoding='UTF-8') == 'ℕ' - bval = u'ℕ'.encode(encoding='UTF-8') + bval = 'ℕ'.encode(encoding='UTF-8') actlen = len(bval) assert uas.get_size(bval) == actlen assert uas.get_size_cr(bval) == actlen @@ -919,7 +916,7 @@ def test08_string_operators(self): assert s1+s2 == "Hello, World!" assert s2+s1 == ", World!Hello" - s2 = u", World!" + s2 = ", World!" assert s1+s2 == "Hello, World!" assert s2+s1 == ", World!Hello" @@ -950,10 +947,10 @@ def EQ(result, init, methodname, *args): assert S.npos == S.size_type(-1) # -- method decode - s = S(u'\xe9') - assert s.decode('utf-8') == u'\xe9' - assert s.decode('utf-8', "strict") == u'\xe9' - assert s.decode(encoding='utf-8') == u'\xe9' + s = S('\xe9') + assert s.decode('utf-8') == '\xe9' + assert s.decode('utf-8', "strict") == '\xe9' + assert s.decode(encoding='utf-8') == '\xe9' # -- method split (only Python) assert S("a b c").split() == ['a', 'b', 'c'] @@ -1752,10 +1749,10 @@ def test03_initialize_from_set(self): assert list(range(N)) == list(s) with raises(TypeError): - s = cppyy.gbl.std.set[int](set([1, "2"])) + s = cppyy.gbl.std.set[int]({1, "2"}) with raises(TypeError): - s = cppyy.gbl.std.set[int](set(["aap", "noot", "mies"])) + s = cppyy.gbl.std.set[int]({"aap", "noot", "mies"}) @mark.xfail(run=not(IS_MAC and IS_CLING)) def test04_set_cpp17_style(self): From c9f2fe2d00ff50544062f8ee80f8a20c4be5ea47 Mon Sep 17 00:00:00 2001 From: mcbarton <150042563+mcbarton@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:36:13 +0100 Subject: [PATCH 2/4] Try fix --- test/datatypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/datatypes.h b/test/datatypes.h index 5f4ec1f9..5f5a11b8 100644 --- a/test/datatypes.h +++ b/test/datatypes.h @@ -608,8 +608,8 @@ static const char g_c_char = 'z'; static const signed char g_c_schar = 'y'; static const unsigned char g_c_uchar = 'x'; static const wchar_t g_c_wchar = L'U'; -static const char16_t g_c_char16 = '\u6c34'; -static const char32_t g_c_char32 = '\U0001f34c'; +static const char16_t g_c_char16 = str('\u6c34', 'utf-16') ; +static const char32_t g_c_char32 = str('\U0001f34c', 'utf-32'); #if __cplusplus > 201402L static const std::byte g_c_byte = (std::byte)'u'; #endif From c8b48b9426a7da0121ef26b92cb90225aa320864 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 8 Apr 2025 14:08:05 +0100 Subject: [PATCH 3/4] Revert changes to datatypes.cxx and .h files --- test/datatypes.cxx | 8 ++++---- test/datatypes.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/datatypes.cxx b/test/datatypes.cxx index 2e54d38e..7881f5c1 100644 --- a/test/datatypes.cxx +++ b/test/datatypes.cxx @@ -613,8 +613,8 @@ char g_char = 'w'; signed char g_schar = 'v'; unsigned char g_uchar = 'u'; wchar_t g_wchar = L'U'; -char16_t g_char16 = '\u6c21'; -char32_t g_char32 = '\u6c21'; +char16_t g_char16 = u'\u6c21'; +char32_t g_char32 = U'\u6c21'; #if __cplusplus > 201402L std::byte g_byte = (std::byte)'x'; #endif @@ -672,8 +672,8 @@ std::string get_some_global_string() { return g_some_global_string; } std::string g_some_global_string2 = "C++"; std::string get_some_global_string2() { return g_some_global_string2; } -const char16_t* g_some_global_string16 = "z\u00df\u6c34"; -const char32_t* g_some_global_string32 = "z\u00df\u6c34\U0001f34c"; +const char16_t* g_some_global_string16 = u"z\u00df\u6c34"; +const char32_t* g_some_global_string32 = U"z\u00df\u6c34\U0001f34c"; std::string SomeStaticDataNS::s_some_static_string = "C++"; std::string SomeStaticDataNS::get_some_static_string() { return s_some_static_string; } diff --git a/test/datatypes.h b/test/datatypes.h index 5f5a11b8..8a2d5d51 100644 --- a/test/datatypes.h +++ b/test/datatypes.h @@ -608,8 +608,8 @@ static const char g_c_char = 'z'; static const signed char g_c_schar = 'y'; static const unsigned char g_c_uchar = 'x'; static const wchar_t g_c_wchar = L'U'; -static const char16_t g_c_char16 = str('\u6c34', 'utf-16') ; -static const char32_t g_c_char32 = str('\U0001f34c', 'utf-32'); +static const char16_t g_c_char16 = u'\u6c34'; +static const char32_t g_c_char32 = U'\U0001f34c'; #if __cplusplus > 201402L static const std::byte g_c_byte = (std::byte)'u'; #endif From 7114296b650b05f2f8c1c15fb92ee464e53f28ef Mon Sep 17 00:00:00 2001 From: mcbarton Date: Tue, 8 Apr 2025 14:10:57 +0100 Subject: [PATCH 4/4] Revert changes to datatypes.cxx --- test/datatypes.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/datatypes.cxx b/test/datatypes.cxx index 7881f5c1..31641c3c 100644 --- a/test/datatypes.cxx +++ b/test/datatypes.cxx @@ -13,8 +13,8 @@ CppyyTestData::CppyyTestData() : m_const_int(17), m_owns_arrays(false) m_schar = 'b'; m_uchar = 'c'; m_wchar = L'D'; - m_char16 = '\u00df'; - m_char32 = '\u00df'; + m_char16 = u'\u00df'; + m_char32 = U'\u00df'; #if __cplusplus > 201402L m_byte = (std::byte)'d'; #endif @@ -336,8 +336,8 @@ void CppyyTestData::set_enum_cr(const EWhat& w) { m_enum = void CppyyTestData::set_bool_r(bool& b) { b = true; } void CppyyTestData::set_char_r(char& c) { c = 'a'; } void CppyyTestData::set_wchar_r(wchar_t& wc) { wc = 'b'; } -void CppyyTestData::set_char16_r(char16_t& c16) { c16 = '\u6c24'; } -void CppyyTestData::set_char32_r(char32_t& c32) { c32 = '\U0001f34e'; } +void CppyyTestData::set_char16_r(char16_t& c16) { c16 = u'\u6c24'; } +void CppyyTestData::set_char32_r(char32_t& c32) { c32 = U'\U0001f34e'; } void CppyyTestData::set_schar_r(signed char& sc) { sc = 'c'; } void CppyyTestData::set_uchar_r(unsigned char& uc) { uc = 'd'; } #if __cplusplus > 201402L @@ -359,8 +359,8 @@ void CppyyTestData::set_ldouble_r(long double& ld) { ld = 10.l; } void CppyyTestData::set_bool_p(bool* b) { *b = true; } void CppyyTestData::set_char_p(char* c) { *c = 'a'; } void CppyyTestData::set_wchar_p(wchar_t* wc) { *wc = 'b'; } -void CppyyTestData::set_char16_p(char16_t* c16) { *c16 = '\u6c24'; } -void CppyyTestData::set_char32_p(char32_t* c32) { *c32 = '\U0001f34e'; } +void CppyyTestData::set_char16_p(char16_t* c16) { *c16 = u'\u6c24'; } +void CppyyTestData::set_char32_p(char32_t* c32) { *c32 = U'\U0001f34e'; } void CppyyTestData::set_schar_p(signed char* sc) { *sc = 'c'; } void CppyyTestData::set_uchar_p(unsigned char* uc) { *uc = 'd'; } #if __cplusplus > 201402L @@ -393,11 +393,11 @@ void CppyyTestData::set_wchar_ppa(wchar_t** wc) { } void CppyyTestData::set_char16_ppa(char16_t** c16) { (*c16) = new char16_t[3]; - (*c16)[0] = '\u6c24'; (*c16)[1] = '\u6c25'; (*c16)[2] = '\u6c26'; + (*c16)[0] = u'\u6c24'; (*c16)[1] = u'\u6c25'; (*c16)[2] = u'\u6c26'; } void CppyyTestData::set_char32_ppa(char32_t** c32) { (*c32) = new char32_t[3]; - (*c32)[0] = '\U0001f34d'; (*c32)[1] = '\U0001f34e'; (*c32)[2] = '\U0001f34f'; + (*c32)[0] = U'\U0001f34d'; (*c32)[1] = U'\U0001f34e'; (*c32)[2] = U'\U0001f34f'; } void CppyyTestData::set_schar_ppa(signed char** sc) { (*sc) = new signed char[3]; @@ -551,8 +551,8 @@ char CppyyTestData::s_char = 'c'; signed char CppyyTestData::s_schar = 's'; unsigned char CppyyTestData::s_uchar = 'u'; wchar_t CppyyTestData::s_wchar = L'U'; -char16_t CppyyTestData::s_char16 = '\u6c29'; -char32_t CppyyTestData::s_char32 = '\U0001f34b'; +char16_t CppyyTestData::s_char16 = u'\u6c29'; +char32_t CppyyTestData::s_char32 = U'\U0001f34b'; #if __cplusplus > 201402L std::byte CppyyTestData::s_byte = (std::byte)'b'; #endif