diff --git a/py_src/gpiod/libgpiodcxx/__init__.py b/py_src/gpiod/libgpiodcxx/__init__.py index 97c0d89..ec97edd 100644 --- a/py_src/gpiod/libgpiodcxx/__init__.py +++ b/py_src/gpiod/libgpiodcxx/__init__.py @@ -21,6 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from copy import copy from ctypes import get_errno from datetime import timedelta, datetime from errno import ENOENT @@ -232,8 +233,7 @@ def get_line(self, offset: int) -> line: errno, strerror(errno), "error getting GPIO line from chip" ) - # Failed to deepcopy due to pointer of ctypes - return line(line_struct, chip(chip_shared=self._m_chip)) + return line(line_struct, copy(self)) def find_line(self, name: str) -> line: """ @@ -255,12 +255,7 @@ def find_line(self, name: str) -> line: errno, strerror(errno), "error looking up GPIO line by name" ) - # Failed to deepcopy due to pointer of ctypes - return ( - line(line_struct, chip(chip_shared=self._m_chip)) - if bool(line_struct) - else line() - ) + return line(line_struct, copy(self)) if bool(line_struct) else line() def get_lines(self, offsets: List[int]) -> line_bulk: """