From f4a726da402fc0e18994f8b607302800db56f101 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Mon, 27 Apr 2026 15:12:34 +0200 Subject: [PATCH] GH-135357: Add socket.SO_PASSRIGHTS constant (#135355) Constant added to Linux 6.16. See the LWN article: https://lwn.net/Articles/1023085/ Co-authored-by: Brian Schubert Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Victor Stinner Co-authored-by: Peter Bierma --- Doc/library/socket.rst | 1 + .../2025-06-10-17-30-55.gh-issue-135357.sUXU1W.rst | 1 + Modules/socketmodule.c | 3 +++ 3 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-06-10-17-30-55.gh-issue-135357.sUXU1W.rst diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 71747d5f515a..96bc9e7a0d61 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -486,6 +486,7 @@ The AF_* and SOCK_* constants are now :class:`AddressFamily` and .. versionchanged:: 3.15 ``IPV6_HDRINCL`` was added. + Added support for ``SO_PASSRIGHTS`` on Linux platforms when available. .. data:: AF_CAN diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-10-17-30-55.gh-issue-135357.sUXU1W.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-10-17-30-55.gh-issue-135357.sUXU1W.rst new file mode 100644 index 000000000000..378bb59de793 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-10-17-30-55.gh-issue-135357.sUXU1W.rst @@ -0,0 +1 @@ +Add support for :data:`!socket.SO_PASSRIGHTS` on Linux. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index f1a55db229e1..f5993fc8fdaa 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -8276,6 +8276,9 @@ socket_exec(PyObject *m) #ifdef SO_BINDTODEVICE ADD_INT_MACRO(m, SO_BINDTODEVICE); #endif +#ifdef SO_PASSRIGHTS + ADD_INT_MACRO(m, SO_PASSRIGHTS); +#endif #ifdef SO_BINDTOIFINDEX ADD_INT_MACRO(m, SO_BINDTOIFINDEX); #endif -- 2.47.3