From 490f27b8c92c84e55e3e8d169d709ab21d6e9e74 Mon Sep 17 00:00:00 2001 From: cecille Date: Fri, 16 Aug 2024 11:46:28 -0400 Subject: [PATCH] Change exemption to not carry chip_error reference chip_error is a ctypes struct with a const char* pointer internally. This cannot be pickled, so it's causing problems with the mobly framework. --- src/controller/python/chip/exceptions/__init__.py | 14 +++++--------- src/controller/python/chip/native/__init__.py | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/controller/python/chip/exceptions/__init__.py b/src/controller/python/chip/exceptions/__init__.py index c7f692e9284d26..b293a68eac9434 100644 --- a/src/controller/python/chip/exceptions/__init__.py +++ b/src/controller/python/chip/exceptions/__init__.py @@ -39,21 +39,17 @@ class ChipStackException(Exception): class ChipStackError(ChipStackException): - def __init__(self, chip_error: PyChipError, msg=None): - self._chip_error = chip_error - self.msg = msg if msg else "Chip Stack Error %d" % chip_error.code + def __init__(self, code: int, msg=None): + self.code = code + self.msg = msg if msg else "Chip Stack Error %d" % self.code @classmethod def from_chip_error(cls, chip_error: PyChipError) -> ChipStackError: - return cls(chip_error, str(chip_error)) - - @property - def chip_error(self) -> PyChipError | None: - return self._chip_error + return cls(chip_error.code, str(chip_error)) @property def err(self) -> int: - return self._chip_error.code + return self.code def __str__(self): return self.msg diff --git a/src/controller/python/chip/native/__init__.py b/src/controller/python/chip/native/__init__.py index 518339017b587c..4c8b58f1277b78 100644 --- a/src/controller/python/chip/native/__init__.py +++ b/src/controller/python/chip/native/__init__.py @@ -69,7 +69,7 @@ class ErrorSDKPart(enum.IntEnum): class PyChipError(ctypes.Structure): ''' The ChipError for Python library. - We are using the following struct for passing the infomations of CHIP_ERROR between C++ and Python: + We are using the following struct for passing the information of CHIP_ERROR between C++ and Python: ```c struct PyChipError