def _check(ret): if hasattr(ret, 'value'): ret = ret.value if ret != 0: raise USBError(_lib.openusb_strerror(ret), ret, _openusb_errno[ret]) return ret
def _check(ret): if hasattr(ret, 'value'): ret = ret.value if ret < 0: if ret == LIBUSB_ERROR_NOT_SUPPORTED: raise NotImplementedError(_strerror(ret)) else: raise USBError(_strerror(ret), ret, _libusb_errno[ret]) return ret
def _check(ret): if ret is None: errmsg = _lib.usb_strerror() else: if hasattr(ret, 'value'): ret = ret.value if ret < 0: errmsg = _lib.usb_strerror() # No error means that we need to get the error # message from the return code # Thanks to Nicholas Wheeler to point out the problem... # Also see issue #2860940 if errmsg.lower() == 'no error': errmsg = os.strerror(-ret) else: return ret raise USBError(errmsg, ret)