]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228) (GH-154236)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 20 Jul 2026 09:44:43 +0000 (11:44 +0200)
committerGitHub <noreply@github.com>
Mon, 20 Jul 2026 09:44:43 +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 cddf817750d9fdeaf6416d15b2c7a63f95d865b6..debe861b139ade6da4e5a2d4f9be68042b8f32b6 100644 (file)
@@ -8715,7 +8715,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