Skip to content

gh-149611: Explain return values for Path.write_text() and Path.write_bytes()#149629

Merged
nedbat merged 4 commits intopython:mainfrom
omkar-334:return-number
May 10, 2026
Merged

gh-149611: Explain return values for Path.write_text() and Path.write_bytes()#149629
nedbat merged 4 commits intopython:mainfrom
omkar-334:return-number

Conversation

@omkar-334
Copy link
Copy Markdown
Contributor

@omkar-334 omkar-334 commented May 10, 2026

pathlib.Path.write_text and pathlib.Path.write_bytes both return an integer from the underlying file object's .write() call (number of characters and number of bytes, respectively), but neither the Sphinx documentation nor the docstrings mention this.

Issue - #149611

@omkar-334 omkar-334 requested a review from barneygale as a code owner May 10, 2026 02:26
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 10, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 10, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 10, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 10, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32625351 | 📁 Comparing 4e81514 against main (cc5cf14)

  🔍 Preview build  

2 files changed
± library/pathlib.html
± whatsnew/changelog.html

@StanFromIreland StanFromIreland requested a review from nedbat May 10, 2026 07:57
@nedbat
Copy link
Copy Markdown
Member

nedbat commented May 10, 2026

Thanks. I would have thought "Returns" was more correct (file objects' write() docstring uses "Returns"), but there are more "Return" in the .rst files than "Returns", so this is good to go.

@omkar-334
Copy link
Copy Markdown
Contributor Author

Thanks. I would have thought "Returns" was more correct (file objects' write() docstring uses "Returns"), but there are more "Return" in the .rst files than "Returns", so this is good to go.

Glad to have contributed... Indeed at first look I thought Returns looks better but i noticed the same thing.

@nedbat nedbat enabled auto-merge (squash) May 10, 2026 17:04
@picnixz
Copy link
Copy Markdown
Member

picnixz commented May 10, 2026

(Updating the branch to fix possible CI failures)

@nedbat nedbat merged commit a8e3247 into python:main May 10, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants