Patch Detail
Show a patch.
GET /api/patches/26778/?format=api
{ "id": 26778, "url": "https://patchwork.libcamera.org/api/patches/26778/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26778/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260519072152.346204-1-barnabas.pocze@ideasonboard.com>", "date": "2026-05-19T07:21:52", "name": "[RFC,v1] py: Use smart holder for `Camera` if available", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "49420148bc090e8a93a8289d101877d1f2dc5817", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26778/mbox/", "series": [ { "id": 5955, "url": "https://patchwork.libcamera.org/api/series/5955/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5955", "date": "2026-05-19T07:21:52", "name": "[RFC,v1] py: Use smart holder for `Camera` if available", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5955/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26778/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26778/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8CA5BBDCBC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 May 2026 07:21:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 952DF63024;\n\tTue, 19 May 2026 09:21:57 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E3B762E6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2026 09:21:55 +0200 (CEST)", "from pb-laptop.local (unknown\n\t[IPv6:2a01:cb1d:8f2:800:9eb6:570e:4fb2:add3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B4A62BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2026 09:21:42 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"s9N2srcy\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1779175302;\n\tbh=vAkbxGLab49QdgbxDEu/qOzV+H6eAbqEuztwpB88SbM=;\n\th=From:To:Subject:Date:From;\n\tb=s9N2srcymyR8DEnT0FZ1jooRj/L3RkTY7ONfSn0orKi9hAXnpy1E8e2acslpy/b8c\n\t9u77huW6yT7q6Gchey0+m4SLoMHligBl0FAsnZiqqRMnQ2x2StL8HSpLhBzzFfaSuy\n\tsXEuD5JJ2gbwXe+6tIeh0SYSId0fr/oAxN+kpy5M=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v1] py: Use smart holder for `Camera` if available", "Date": "Tue, 19 May 2026 09:21:52 +0200", "Message-ID": "<20260519072152.346204-1-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.54.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The `Camera` class has a private destructor, so `std::shared_ptr<>` cannot\nbe used as a holder type. In recent versions of pybind11, the custom holder\ntype that was used no longer works:\n\n RuntimeError: Unable to convert std::shared_ptr<T> to Python when the bound\n type does not use std::shared_ptr or py::smart_holder as its holder type\n\nThis appears to be intentional and the fact that it worked is accidental.\n\nFix that by using a \"smart holder\" since pybind11 3.x, and falling back to\nthe custom one in previous versions.\n\nLink: https://github.com/pybind/pybind11/issues/6064\nCloses: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/334\n---\n src/py/libcamera/py_main.cpp | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\nindex d0ef6915b..3b101f996 100644\n--- a/src/py/libcamera/py_main.cpp\n+++ b/src/py/libcamera/py_main.cpp\n@@ -34,6 +34,7 @@ LOG_DEFINE_CATEGORY(Python)\n \n }\n \n+#if PYBIND11_VERSION_MAJOR < 3\n /*\n * This is a holder class used only for the Camera class, for the sole purpose\n * of avoiding the compilation issue with Camera's private destructor.\n@@ -79,6 +80,13 @@ private:\n \n PYBIND11_DECLARE_HOLDER_TYPE(T, PyCameraSmartPtr<T>)\n \n+using PyCameraHolder = PyCameraSmartPtr<Camera>;\n+using PyCameraArg = PyCameraSmartPtr<Camera>;\n+#else\n+using PyCameraHolder = py::smart_holder;\n+using PyCameraArg = std::shared_ptr<Camera>;\n+#endif\n+\n /*\n * Note: global C++ destructors can be ran on this before the py module is\n * destructed.\n@@ -103,7 +111,7 @@ PYBIND11_MODULE(_libcamera, m)\n \t */\n \n \tauto pyCameraManager = py::class_<PyCameraManager, std::shared_ptr<PyCameraManager>>(m, \"CameraManager\");\n-\tauto pyCamera = py::class_<Camera, PyCameraSmartPtr<Camera>>(m, \"Camera\");\n+\tauto pyCamera = py::class_<Camera, PyCameraHolder>(m, \"Camera\");\n \tauto pySensorConfiguration = py::class_<SensorConfiguration>(m, \"SensorConfiguration\");\n \tauto pyCameraConfiguration = py::class_<CameraConfiguration>(m, \"CameraConfiguration\");\n \tauto pyCameraConfigurationStatus = py::enum_<CameraConfiguration::Status>(pyCameraConfiguration, \"Status\");\n@@ -347,7 +355,7 @@ PYBIND11_MODULE(_libcamera, m)\n \t\t.def(\"range\", &StreamFormats::range);\n \n \tpyFrameBufferAllocator\n-\t\t.def(py::init<PyCameraSmartPtr<Camera>>(), py::keep_alive<1, 2>())\n+\t\t.def(py::init<PyCameraArg>(), py::keep_alive<1, 2>())\n \t\t.def(\"allocate\", [](FrameBufferAllocator &self, Stream *stream) {\n \t\t\tint ret = self.allocate(stream);\n \t\t\tif (ret < 0)\n", "prefixes": [ "RFC", "v1" ] }