Skip to contentSkip to conversation

bindings: python: allow releasing LineRequest multiple times

PATCH Superseded Vincent Fazio 2 participants 2 messages Apr 2 – Apr 3 GPIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: python: allow releasing LineRequest multiple times

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

---
 bindings/python/gpiod/line_request.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
bindings/python/gpiod/line_request.py +3 -3
index 0287791..a271080 100644
@@ -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:
         """
Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines · Vincent Fazio

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

Same comment as for chips. A comment in the code would do too.

Bart