public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Vincent Fazio <vfazio@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: Vincent Fazio <vfazio@gmail.com>
Subject: [libgpiod][PATCH] bindings: python: allow releasing LineRequest multiple times
Date: Thu,  2 Apr 2026 18:03:21 -0500	[thread overview]
Message-ID: <20260402230321.6579-1-vfazio@gmail.com> (raw)

Allow releasing a LineRequest mulitple times without throwing a
RequestReleasedError to adhere to common Python semantics.

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
 bindings/python/gpiod/line_request.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
index 0287791..a271080 100644
--- a/bindings/python/gpiod/line_request.py
+++ b/bindings/python/gpiod/line_request.py
@@ -75,9 +75,9 @@ class LineRequest:
         Release this request and free all associated resources. The object must
         not be used after a call to this method.
         """
-        self._check_released()
-        cast("_ext.Request", self._req).release()
-        self._req = None
+        if self._req is not None:
+            self._req.release()
+            self._req = None
 
     def get_value(self, line: int | str) -> Value:
         """
-- 
2.43.0


             reply	other threads:[~2026-04-02 23:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 23:03 Vincent Fazio [this message]
2026-04-03  9:06 ` [libgpiod][PATCH] bindings: python: allow releasing LineRequest multiple times Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260402230321.6579-1-vfazio@gmail.com \
    --to=vfazio@gmail.com \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox