Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
libgpiodcxx: use copy() to return line in chip
Browse files Browse the repository at this point in the history
  • Loading branch information
hhk7734 committed May 7, 2020
1 parent f4604a7 commit 3baa80a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions py_src/gpiod/libgpiodcxx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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:
"""
Expand Down

0 comments on commit 3baa80a

Please sign in to comment.