{"id":2219404,"url":"http://patchwork.ozlabs.org/api/patches/2219404/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260402230315.6501-1-vfazio@gmail.com/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260402230315.6501-1-vfazio@gmail.com>","list_archive_url":null,"date":"2026-04-02T23:03:14","name":"[libgpiod] bindings: python: allow closing Chip multiple times","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"18834608c3329672620cdb33a047bafe319b56f8","submitter":{"id":78694,"url":"http://patchwork.ozlabs.org/api/people/78694/?format=json","name":"Vincent Fazio","email":"vfazio@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260402230315.6501-1-vfazio@gmail.com/mbox/","series":[{"id":498559,"url":"http://patchwork.ozlabs.org/api/series/498559/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=498559","date":"2026-04-02T23:03:14","name":"[libgpiod] bindings: python: allow closing Chip multiple times","version":1,"mbox":"http://patchwork.ozlabs.org/series/498559/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219404/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219404/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-gpio+bounces-34621-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=AIGKo1oB;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-gpio+bounces-34621-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"AIGKo1oB\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.167.174","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmy7y2mwWz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 10:03:26 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 3039B302E7E8\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  2 Apr 2026 23:03:24 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 212343370EA;\n\tThu,  2 Apr 2026 23:03:21 +0000 (UTC)","from mail-oi1-f174.google.com (mail-oi1-f174.google.com\n [209.85.167.174])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F0A41A6825\n\tfor <linux-gpio@vger.kernel.org>; Thu,  2 Apr 2026 23:03:19 +0000 (UTC)","by mail-oi1-f174.google.com with SMTP id\n 5614622812f47-4670464029eso839649b6e.2\n        for <linux-gpio@vger.kernel.org>;\n Thu, 02 Apr 2026 16:03:19 -0700 (PDT)","from Zephyrus.localdomain ([131.93.209.211])\n        by smtp.gmail.com with ESMTPSA id\n 006d021491bc7-680a882d96dsm2779753eaf.9.2026.04.02.16.03.17\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Thu, 02 Apr 2026 16:03:17 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775171000; cv=none;\n b=d6GnYFxPW2HP8/HeSsCz6mOIUNHpEl1h7UO/IWhkA24MOqWBnPay+B8pavw3pIRHJNPsxYWzItHUKuzR/ZVdisyQ5q8/gxgZ6UGJJRGV/t7LWKoTIP4YD76Uz7R+lkuyZyZGitUhIvzZ4pc223BG7aaONbgsljtePY9GxhfVwr8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775171000; c=relaxed/simple;\n\tbh=8FQO4M5dyAjgxX+o/CyHskFfh+i0c9weSwdG9dip35I=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=J62Efn84CoQqn+Pr51GSs3OkOseDgKIaRq3S5B0xNnGW9h91bwTiSBr2vjK/uSYjT1vDCLF2cOs5gCKkm/QwImmtDb7Vg1h9QPXYoMbv1niIVcqaONTDPJpvDaHEoh+6g4pVpS89lbCc9+F5UDayAbVLHnYpEPVuEcJpWAGk0L8=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=AIGKo1oB; arc=none smtp.client-ip=209.85.167.174","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1775170998; x=1775775798;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:from:to:cc:subject:date:message-id:reply-to;\n        bh=rqjkeVly6X+nXBuyA4NDGDCxgrqfG9zYTkKJXm8+2sc=;\n        b=AIGKo1oByykc8tjQrup5TCJQOIwDqxD4Si2Z6qpmuyL433/0Yyzx1gdPCVHcny/UZo\n         k0DcJjrVDBuaVhKSbMuBzxI9BXVOX6YApuqqJPd0zOP7ONcWbI+VPeJlloLl0VbKBm7g\n         RCrIcXrptKhu6Ysc+fbVhpVLUF4ad1usvZVPDrFCOD1LpUaWASZmOuHUpvJAg/YwJqdD\n         MzFw0sttal0PoEDjnTJYhh9zn1byLZ7I2N/cpIhWfQVo5q0NdBkjyYazcJSbcnnRgzCr\n         NoRXijHjpuCiaFC+zowjDBmFmas6DLXtIiZyfxjV4tpoksCMyeMm5M7sUB4hBLDMPWay\n         XRhw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1775170998; x=1775775798;\n        h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=rqjkeVly6X+nXBuyA4NDGDCxgrqfG9zYTkKJXm8+2sc=;\n        b=BtklRD5WKR8bBYX2CJ56fmIbFgH9iq5JoPdDbqrHTFFpjF5aCkMJQiZJlSit0067cw\n         sw4ecR19Z/DuqfalU6jtrXRcqzZpZnrivD4TzRMLIgxQghvb74BtKFxOJ6cuvWqG4L4n\n         V51z3V9DF2c2YMtx4qaWE1plSWbSA9cAxw+jNFUgiPpD1Qglru0JX7bvoZQqqCrYV2w1\n         pFHKIun2J/+sf2Mqq70cOohqclQMEeVgOnm89FRw4HE0OIBKSm2ZpVUd+SCuI7Q9TrL6\n         VaVBf7+OmjoRe4UCvuGdtDDbtZL2zQrO8zG94WFCJMkT2dKcgH7vLdybgmNn57169UoQ\n         YB2A==","X-Gm-Message-State":"AOJu0YzBDPIUroH4ZvYpiFipqyg+exc1TlQeLTXh/bLwD1Eo/9xzilCx\n\tkX+QBQIqOA3DByT6BHEgcnzsYH86YB+ITpCj5fcpT4sm6b8FBd0duaGSpkAITA==","X-Gm-Gg":"ATEYQzyp+E0JQ6/bR9cKSWkurCALVOlgNk2NrpGlzGn8vc+MUT+Qe+x9NEYoyoV8wbh\n\tYtLMXDkRzHtkRFtmRA+zbJNd9XxhxDFOT5AQoaZ681WnYX9UGa8UsrBqKkw9rG3qzQcivI5qe5z\n\tUc/EegBprcH+de/iVouzPp3A7CCSpRNzYyQozLYNFjFHeVXALR+36xboyCSNzhukF/kLs79tAwO\n\tnQToaHnunQQIx+ZmKTSnHe7WxR51btLKXo2i5eALdz+TbNJuoGg5sdtKdG5LC5f9nTwV9cioaYk\n\tEB+oE/QrW9YD4eklpbXZxmZ43nbPxJQb2TMMzc5YMUSddGBQ/bicxTkjYWpg63DA+EmTpt49L8R\n\tWHQxNgy7dXpXlBXzn906cZZtxhfWnrODoTVV8gVAtIE5NmomfPNnexF/bj6GxU1n51wXLFKfd29\n\tHOX9PYZf0MtEbzEInhs+EPMBAQR4RfaYrNPZaR4+LPvh+0dAcHVambPsIpaSMvJw==","X-Received":"by 2002:a05:6820:188a:b0:67e:4140:769a with SMTP id\n 006d021491bc7-6821d24030dmr551027eaf.7.1775170998225;\n        Thu, 02 Apr 2026 16:03:18 -0700 (PDT)","From":"Vincent Fazio <vfazio@gmail.com>","To":"linux-gpio@vger.kernel.org","Cc":"Vincent Fazio <vfazio@gmail.com>","Subject":"[libgpiod][PATCH] bindings: python: allow closing Chip multiple times","Date":"Thu,  2 Apr 2026 18:03:14 -0500","Message-ID":"<20260402230315.6501-1-vfazio@gmail.com>","X-Mailer":"git-send-email 2.43.0","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"Allow closing a Chip mulitple times without throwing a ChipClosedError\nto adhere to common Python semantics.\n\nSigned-off-by: Vincent Fazio <vfazio@gmail.com>\n---\n bindings/python/gpiod/chip.py       | 6 +++---\n bindings/python/tests/tests_chip.py | 8 --------\n 2 files changed, 3 insertions(+), 11 deletions(-)","diff":"diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py\nindex 8113fa9..6b7b32b 100644\n--- a/bindings/python/gpiod/chip.py\n+++ b/bindings/python/gpiod/chip.py\n@@ -99,9 +99,9 @@ class Chip:\n         Close the associated GPIO chip descriptor. The chip object must no\n         longer be used after this method is called.\n         \"\"\"\n-        self._check_closed()\n-        cast(\"_ext.Chip\", self._chip).close()\n-        self._chip = None\n+        if self._chip is not None:\n+            self._chip.close()\n+            self._chip = None\n \n     def get_info(self) -> ChipInfo:\n         \"\"\"\ndiff --git a/bindings/python/tests/tests_chip.py b/bindings/python/tests/tests_chip.py\nindex d5a64b3..9007885 100644\n--- a/bindings/python/tests/tests_chip.py\n+++ b/bindings/python/tests/tests_chip.py\n@@ -184,14 +184,6 @@ class ClosedChipCannotBeUsed(TestCase):\n             with chip:\n                 _ = chip.fd\n \n-    def test_close_chip_twice(self) -> None:\n-        sim = gpiosim.Chip(label=\"foobar\")\n-        chip = gpiod.Chip(sim.dev_path)\n-        chip.close()\n-\n-        with self.assertRaises(gpiod.ChipClosedError):\n-            chip.close()\n-\n \n class StringRepresentation(TestCase):\n     def setUp(self) -> None:\n","prefixes":["libgpiod"]}