class _StrWrap():
"""Wrap a FFI Cdata object
This class is a proxy class which auto-convert FFI string to Python
string. It must be used only on object containing string data.
Original CFFI string can always be accessed by prefixing the property with
an underscore.
"""
def __init__(self, obj):
self.obj = obj
def __setattr__(self, key, value):
if key == 'obj':
return super().__setattr__(key, value)
setattr(self.obj, key, value)
def __getattr__(self, key):
try:
attr = getattr(self.obj, key)
except AttributeError as origin_exc:
# Remove the first underscore if exists
if key.startswith('_'):
try:
return getattr(self.obj, key[1:])
except AttributeError:
raise origin_exc
raise origin_exc
return _cstr(attr)
If you run on python2 will get this error.
return super().setattr(key, value)
TypeError: super() takes at least 1 argument (0 given)
Exception TypeError: "'NoneType' object is not callable" in <bound method HelloTriangleApplication.del of <main.HelloTriangleApplication object at 0x000000000306F888>> ignored
This is not supported on python2
If you run on python2 will get this error. return super().setattr(key, value) TypeError: super() takes at least 1 argument (0 given) Exception TypeError: "'NoneType' object is not callable" in <bound method HelloTriangleApplication.del of <main.HelloTriangleApplication object at 0x000000000306F888>> ignored