]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 20 Jul 2026 08:48:14 +0000 (11:48 +0300)
committerGitHub <noreply@github.com>
Mon, 20 Jul 2026 08:48:14 +0000 (08:48 +0000)
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 02d25adddd6267578f4b6718dec64bd4bbe6cfc5..69f01e04244d5bd028afda11a56e6f6d6794a6e5 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