[3.14] gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228) (GH-154236)

serhiy-storchaka <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/1fad2bbc6750e827c3b9799aeadde2b7706bbaa9
commit: 1fad2bbc6750e827c3b9799aeadde2b7706bbaa9
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-07-20T12:44:43+03:00
summary:

[3.14] gh-154227: Fix os.posix_openpt() on OpenBSD (GH-154228) (GH-154236)

(cherry picked from commit d01b90cf33f8f77172eb9f445dbc2ed0055ffd3b)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>

files:
A Misc/NEWS.d/next/Library/2026-07-20-14-00-00.gh-issue-154227.openpt.rst
M 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
index 00000000000000..e33d090d78c593
--- /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 cddf817750d9fd..debe861b139ade 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.