{"id":2225987,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2225987/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260422012041.39933-6-vfazio@gmail.com/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20260422012041.39933-6-vfazio@gmail.com>","list_archive_url":null,"date":"2026-04-22T01:20:37","name":"[libgpiod,5/9] bindings: python: use suggestions from upgrade_pythoncapi.py","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6b46560fe63a9f849a2ebbc679adf6f99fadb3cd","submitter":{"id":78694,"url":"http://patchwork.ozlabs.org/api/1.2/people/78694/?format=json","name":"Vincent Fazio","email":"vfazio@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260422012041.39933-6-vfazio@gmail.com/mbox/","series":[{"id":500906,"url":"http://patchwork.ozlabs.org/api/1.2/series/500906/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=500906","date":"2026-04-22T01:20:32","name":"bindings: python: modernize C extensions","version":1,"mbox":"http://patchwork.ozlabs.org/series/500906/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225987/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225987/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-gpio+bounces-35326-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=CutMrMtj;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-35326-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=\"CutMrMtj\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.48","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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0hJm0vw8z1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 11:21:44 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 3F96A302BA4B\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 01:21:03 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id F399F2D3A6A;\n\tWed, 22 Apr 2026 01:21:02 +0000 (UTC)","from mail-ot1-f48.google.com (mail-ot1-f48.google.com\n [209.85.210.48])\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 78E2617BED0\n\tfor <linux-gpio@vger.kernel.org>; Wed, 22 Apr 2026 01:21:01 +0000 (UTC)","by mail-ot1-f48.google.com with SMTP id\n 46e09a7af769-7dbff06e4a6so4789114a34.1\n        for <linux-gpio@vger.kernel.org>;\n Tue, 21 Apr 2026 18:21:01 -0700 (PDT)","from Zephyrus.localdomain ([131.93.209.211])\n        by smtp.gmail.com with ESMTPSA id\n 006d021491bc7-69464eeee56sm9876036eaf.8.2026.04.21.18.20.59\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Tue, 21 Apr 2026 18:20:59 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776820862; cv=none;\n b=eUWi/HJlP7lXRG/SfEh6bRA+vowYG9+OtudmjaDg+sZ/qPIC/ctb/BPSkcZBMpCbJQqJ6ZtnvabKSrXWaZDxiiEJxhzhXO+/Rp164yBAlqyI3UYE4ty7QOBZK6Pf+3roYYafaeg9zs3PWHT/K47Gx1L0hlUQBi41EzzIWDgQsaw=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776820862; c=relaxed/simple;\n\tbh=GCZLfyIbNOnARub7Wn69Ix4LTjbebEeMRo8zT5mSax4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=Gx4YXlcSMknQU1Wuhe4yYelPBZKEqc27qSkD1nMcbcRTlcFwFhA2EeiBVoXSjtOecFsL2q3X7jkWXSRf87Tibp4HvAdLSIS/K/GBZvieAJTW4faj84WS5YeSUT2G5PJt5g4hNe0INxg99cz7YNbevFQxnPnccBInUFtR5kp7VTE=","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=CutMrMtj; arc=none smtp.client-ip=209.85.210.48","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776820860; x=1777425660;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=X1XD3hQYkcduGCjjHcdcY7wdg+6wnPJ7zFhFK7fhs7g=;\n        b=CutMrMtj+pzJQ3hHGYba68X7LfYa0LHYeeANHqcs3I8QWjh5OLRJCC2Tq9kasyRzMk\n         53inMkvg5iP1t6opeOl1NJ3FX+rcSkkz/VRLapbfXZ5tJPZoTReN9Nf0GWygghSqjCAn\n         60ggbaDswbJzHzCO3nqUQSD004L1bzWYAvqdwfgjbJe9JLu6IqQ7o5yh5dVKdvNthpTa\n         vS6BEOZPApiD1UXS2q6vuSIqZlsJhhAzxvR1t9X8O9DKju2i6TTQj1v61FkhxgdZYC24\n         O8xHxFG/KenCNbru0AEbOl9ugeYoysS83qZocoL2Jp9XuvWH8wBD/Qr8QVT4M2FVITA8\n         TJpA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776820860; x=1777425660;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=X1XD3hQYkcduGCjjHcdcY7wdg+6wnPJ7zFhFK7fhs7g=;\n        b=mZ17GEWgj+knql2rINYQ+y2bvTPrWtqjP+HPU/gVtnpkBumNQtqgGKEi6UbvsCZjcz\n         keMEAYOK9JSifAe1fXgCwYYXKeyVDO6eWDHTmlrnu0mvgN7kEnoYBmrJL0ox6hIpKi0I\n         Z3DfkYvd4f1p5QIWC3ZqCS61P4VPpoNxYkdRzfqPs3H49ry1qcZYOKGH7MbcT/49mLPY\n         JEzu6sHt4kfE4jxaGQqZEv44fW12a+pxudxNw8p1+QM5ltfbvvgFhQBDiJse9TaPhL7s\n         Unuqyv3sYw2e8Wf4Fe6UEPCaU3wRtzCHtLoN2HEceJ+cdGE2IMVKRa0rcCkFgCElnb+v\n         OWyw==","X-Gm-Message-State":"AOJu0YyxoAktLGkEnqKEjX3H7ZEVd+ASK7pvo35FjxJ7vLOjB8mN+iiS\n\taEizXDoxYwdraak4+EiiLCbFbZaqRjHtgvlxFjELNdnB/xzmt/SquPKupHFh/g==","X-Gm-Gg":"AeBDievSauK8bCXTZJ8k3ewix7DnpMxREC/Z+DEgmB/pnLBXMhl+DnTPBuq4Pzb+OOd\n\tnpDu2/9x823diSXMUk5sdVQTAIFEupf3pQysJ8moJmIF/tXf0BYbcV5c8VfqhEeuKo7Li2WzYcM\n\tSaouWt+3l5kO6w2noyhEzLH2u8AkDzsVaDIcq5U3J7YLt3RD1Y3Tvs/qBGP+jGiyiPgohI77Bsg\n\tBwr6hA5pvjBqSatzoEQd5qJvHNhllH+VqttdRYaV9I/WhO9fPWX0qe9ioGgV6vYx3LZYihuVhGy\n\ti3lvi6P6fN0wQzDIHNktyVkPevD42E8E7ErEUxL1agAPk9aWHdBCQIXrwkvvNJALJEVrGskd/f9\n\tBCNJ8Wo1E2znesf6Y+ivIrgsbEGUtcKbmvqIiukODsXHiWPxT/rrXYbPddJxbUDFLHxi/llNn58\n\tMqXHfRkL0/nDKVrO/HI+pAFLu0E3CQnWF3FXWwz60iZvP6U0FcEPNjZgYxEYkLS6/2XDGT+AQ5","X-Received":"by 2002:a05:6820:1610:b0:694:8576:5d7a with SMTP id\n 006d021491bc7-69485765e63mr6084461eaf.30.1776820860111;\n        Tue, 21 Apr 2026 18:21:00 -0700 (PDT)","From":"Vincent Fazio <vfazio@gmail.com>","To":"linux-gpio@vger.kernel.org","Cc":"Vincent Fazio <vfazio@gmail.com>","Subject":"[libgpiod][PATCH 5/9] bindings: python: use suggestions from\n upgrade_pythoncapi.py","Date":"Tue, 21 Apr 2026 20:20:37 -0500","Message-ID":"<20260422012041.39933-6-vfazio@gmail.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260422012041.39933-1-vfazio@gmail.com>","References":"<20260422012041.39933-1-vfazio@gmail.com>","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":"The upgrade_pythoncapi.py script performs transforms on C extension\nsources to use new syntax [0]. It's generally used with a shim header\nfor compatibility, but the header is not necessary for these changes.\n\nThe suggested changes are:\n\n  * Use the `Py_IsNone` function introduced in CPython 3.10 [1] over\n    direct comparison to `Py_None`.\n\n  * Use `PyObject_Free` instead of `PyObject_Del` since `PyObject_Del`\n    has been aliased to `PyObject_Free` for nearly 24 years [2] and has\n    been announced as deprecated [3].\n\n[0]: https://pythoncapi-compat.readthedocs.io/en/latest/index.html\n[1]: https://github.com/python/cpython/pull/25227\n[2]: https://github.com/python/cpython/commit/3e7b893899bdaa294a72e894694b099a1d370765\n[3]: https://docs.python.org/3/c-api/allocation.html#deprecated-aliases\n\nSigned-off-by: Vincent Fazio <vfazio@gmail.com>\n---\n bindings/python/gpiod/ext/chip.c    | 4 ++--\n bindings/python/gpiod/ext/common.c  | 2 +-\n bindings/python/gpiod/ext/request.c | 2 +-\n bindings/python/tests/gpiosim/ext.c | 2 +-\n 4 files changed, 5 insertions(+), 5 deletions(-)","diff":"diff --git a/bindings/python/gpiod/ext/chip.c b/bindings/python/gpiod/ext/chip.c\nindex 9061d23..498a5ee 100644\n--- a/bindings/python/gpiod/ext/chip.c\n+++ b/bindings/python/gpiod/ext/chip.c\n@@ -271,7 +271,7 @@ make_request_config(PyObject *consumer_obj, PyObject *event_buffer_size_obj)\n \t\treturn NULL;\n \t}\n \n-\tif (consumer_obj != Py_None) {\n+\tif (!Py_IsNone(consumer_obj)) {\n \t\tconsumer = PyUnicode_AsUTF8(consumer_obj);\n \t\tif (!consumer) {\n \t\t\tgpiod_request_config_free(req_cfg);\n@@ -281,7 +281,7 @@ make_request_config(PyObject *consumer_obj, PyObject *event_buffer_size_obj)\n \t\tgpiod_request_config_set_consumer(req_cfg, consumer);\n \t}\n \n-\tif (event_buffer_size_obj != Py_None) {\n+\tif (!Py_IsNone(event_buffer_size_obj)) {\n \t\tevent_buffer_size = PyLong_AsSize_t(event_buffer_size_obj);\n \t\tif (PyErr_Occurred()) {\n \t\t\tgpiod_request_config_free(req_cfg);\ndiff --git a/bindings/python/gpiod/ext/common.c b/bindings/python/gpiod/ext/common.c\nindex 62201b6..7d2dda7 100644\n--- a/bindings/python/gpiod/ext/common.c\n+++ b/bindings/python/gpiod/ext/common.c\n@@ -12,7 +12,7 @@ void Py_gpiod_dealloc(PyObject *self)\n \tif (ret < 0)\n \t\treturn;\n \n-\tPyObject_Del(self);\n+\tPyObject_Free(self);\n }\n \n PyObject *Py_gpiod_SetErrFromErrno(void)\ndiff --git a/bindings/python/gpiod/ext/request.c b/bindings/python/gpiod/ext/request.c\nindex 9940382..46e07ae 100644\n--- a/bindings/python/gpiod/ext/request.c\n+++ b/bindings/python/gpiod/ext/request.c\n@@ -286,7 +286,7 @@ static PyObject *request_read_edge_events(request_object *self, PyObject *args)\n \tif (!ret)\n \t\treturn NULL;\n \n-\tif (max_events_obj != Py_None) {\n+\tif (!Py_IsNone(max_events_obj)) {\n \t\tmax_events = PyLong_AsSize_t(max_events_obj);\n \t\tif (PyErr_Occurred())\n \t\t\treturn NULL;\ndiff --git a/bindings/python/tests/gpiosim/ext.c b/bindings/python/tests/gpiosim/ext.c\nindex cb5611a..1ebd5af 100644\n--- a/bindings/python/tests/gpiosim/ext.c\n+++ b/bindings/python/tests/gpiosim/ext.c\n@@ -116,7 +116,7 @@ static void chip_dealloc(PyObject *self)\n \tif (ret < 0)\n \t\treturn;\n \n-\tPyObject_Del(self);\n+\tPyObject_Free(self);\n }\n \n static PyObject *chip_dev_path(chip_object *self, void *Py_UNUSED(ignored))\n","prefixes":["libgpiod","5/9"]}