Skip to content

unexpected behavior of tempfile.TemporaryFile() for O_TMPFILE #96531

Open
@zhangyoufu

Description

@zhangyoufu

Bug report

When O_TMPFILE is available:

  1. tempfile.TemporaryFile(mode='wb') opens with O_RDWR instead of O_WRONLY, the opener callback ignores mode argument and always use _bin_openflags
  2. _bin_openflags has both O_CREAT and O_EXCL set, the opener callback removes O_CREAT from flags but leave O_EXCL, this is an undefined behavior according to Linux open(2) manpage

Your environment

  • CPython versions tested on: 3.10
  • Operating system and architecture: Linux x86_64

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions