]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228) (GH-154235)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 20 Jul 2026 09:44:29 +0000 (11:44 +0200)
committerGitHub <noreply@github.com>
Mon, 20 Jul 2026 09:44:29 +0000 (12:44 +0300)
(cherry picked from commit d01b90cf33f8f77172eb9f445dbc2ed0055ffd3b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Misc/NEWS.d/next/Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst [new file with mode: 0644]
Modules/posixmodule.c

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 (file)
index 0000000..e33d090
--- /dev/null
@@ -0,0 +1,2 @@
+Fix :func:`os.posix_openpt` on OpenBSD, where it rejected the
+:data:`~os.O_CLOEXEC` flag.
index b4009b8cb68694e462177057712dca81e4422af1..d4390370cc2f753567ed1b093dcd9c23735331eb 100644 (file)
@@ -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