Skip to content

os.posix_openpt() always fails with EINVAL on OpenBSD #154227

Description

@serhiy-storchaka

Bug report

os.posix_openpt() is unusable on OpenBSD — every call fails:

>>> os.posix_openpt(os.O_RDWR | os.O_NOCTTY)
OSError: [Errno 22] Invalid argument

Modules/posixmodule.c unconditionally adds O_CLOEXEC to the flags, but OpenBSD's posix_openpt(3) returns EINVAL for any flag other than O_RDWR and O_NOCTTY. The function already makes the fd non-inheritable with _Py_set_inheritable() immediately afterwards, so skip the O_CLOEXEC flag on OpenBSD.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesOS-unsupportedextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions