Skip to content

Commit

Permalink
Change exemption to not carry chip_error reference
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cecille committed Aug 16, 2024
1 parent b64a987 commit 490f27b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions src/controller/python/chip/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/chip/native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 490f27b

Please sign in to comment.