From 4aae1285d715db82db4e9fa0c36f1e5e6deac25d Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 20 Jul 2026 11:44:29 +0200 Subject: [PATCH] [3.15] gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228) (GH-154235) (cherry picked from commit d01b90cf33f8f77172eb9f445dbc2ed0055ffd3b) Co-authored-by: Serhiy Storchaka Co-authored-by: Claude Fable 5 --- .../Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst | 2 ++ Modules/posixmodule.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst diff --git a/Misc/NEWS.d/next/Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst b/Misc/NEWS.d/next/Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst new file mode 100644 index 000000000000..e33d090d78c5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst @@ -0,0 +1,2 @@ +Fix :func:`os.posix_openpt` on OpenBSD, where it rejected the +:data:`~os.O_CLOEXEC` flag. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index b4009b8cb686..d4390370cc2f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -9186,7 +9186,9 @@ os_posix_openpt_impl(PyObject *module, int oflag) { int fd; -#if defined(O_CLOEXEC) + // OpenBSD posix_openpt() rejects any flag other than O_RDWR and + // O_NOCTTY; the fd is made non-inheritable below in any case. +#if defined(O_CLOEXEC) && !defined(__OpenBSD__) oflag |= O_CLOEXEC; #endif -- 2.47.3