python / python/cpython

Document that the built-in open() when called with a file descriptor ignores "mode" argument

Open
#95,498 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs topic-IO
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

At https://docs.python.org/3/library/functions.html#open, in the documentation of the mode argument there is no information that this argument is ignored when the function is called with a file descriptor instead of a path.

See Why does os.fdopen ignore mode? SO question. The question talks about os.fdopen() but according to https://docs.python.org/3/library/os.html#os.fdopen

This is an alias of the open() built-in function and accepts the same arguments.

so I think it should be enough to place the information in the documentation of the mode argument of the built-in open() function. This way it would document the built-in open() function but also the os.fdopen() function by virtue of the latter being an alias of the former.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the linked built-in open() documentation and inspect the mode argument description. Check the linked os.fdopen() entry to confirm the alias context, then document that mode is ignored when open() receives a file descriptor; the open() and os.fdopen() documentation should clearly convey this behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.