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