From 3baa80ac6ccc608787ba7fa292287c1d3a8eb7c2 Mon Sep 17 00:00:00 2001 From: Hyeonki Hong Date: Thu, 7 May 2020 13:25:19 +0900 Subject: [PATCH] libgpiodcxx: use copy() to return line in chip --- py_src/gpiod/libgpiodcxx/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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: """