◐ Shell
reader mode source ↗
Skip to content

gh-143866: Verify return value of pathlib write methods in tests#143870

Merged
sobolevn merged 6 commits into
python:mainfrom
b9788213:gh-143866-pathlib-test
Jan 19, 2026
Merged

gh-143866: Verify return value of pathlib write methods in tests#143870
sobolevn merged 6 commits into
python:mainfrom
b9788213:gh-143866-pathlib-test

Conversation

@b9788213

@b9788213 b9788213 commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds assertions to ensure that pathlib.Path.write_text() and pathlib.Path.write_bytes() correctly return the number of bytes written.

Currently, the tests only verify the side effects (file content), which means a regression (like accidentally removing the return statement) would go unnoticed.

Linked Issue

Fixes #143866

@b9788213 b9788213 requested a review from barneygale as a code owner January 15, 2026 14:29
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Jan 15, 2026
@bedevere-app

bedevere-app Bot commented Jan 15, 2026

Copy link
Copy Markdown

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.

@bedevere-app

bedevere-app Bot commented Jan 15, 2026

Copy link
Copy Markdown

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.

@b9788213

Copy link
Copy Markdown
Contributor Author

Ok, i am changed it. Can you add "skip news" label please?

@b9788213

Copy link
Copy Markdown
Contributor Author

Why its failing?

@b9788213 b9788213 force-pushed the gh-143866-pathlib-test branch from b727c7c to 7a8dd6f Compare January 16, 2026 17:54
@picnixz

picnixz commented Jan 18, 2026

Copy link
Copy Markdown
Member

Some flakiness I think.

@b9788213

Copy link
Copy Markdown
Contributor Author

How?

@sobolevn sobolevn added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jan 19, 2026
Hide details View details @sobolevn sobolevn merged commit cb6a662 into python:main Jan 19, 2026
53 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @b9788213 for the PR, and @sobolevn for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 19, 2026
…methods in tests (pythonGH-143870)

(cherry picked from commit cb6a662)

Co-authored-by: b9788213 <b9788213@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
@miss-islington-app

Copy link
Copy Markdown

Sorry, @b9788213 and @sobolevn, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker cb6a662bb0f7a9da9d4ba9dda820053f8d54a9f8 3.13

@bedevere-app

bedevere-app Bot commented Jan 19, 2026

Copy link
Copy Markdown

GH-144029 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jan 19, 2026
@sobolevn

Copy link
Copy Markdown
Member

@b9788213 can you please handle the 3.13 backport manually?

sobolevn added a commit that referenced this pull request Jan 19, 2026
… methods in tests (GH-143870) (#144029)

gh-143866: Verify return value of `pathlib.write_{bytes,text}` methods in tests (GH-143870)
(cherry picked from commit cb6a662)

Co-authored-by: b9788213 <b9788213@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
@b9788213 b9788213 deleted the gh-143866-pathlib-test branch January 20, 2026 12:09
@b9788213

Copy link
Copy Markdown
Contributor Author

Yes, but i dont how to do.

@sobolevn

Copy link
Copy Markdown
Member

@b9788213

Copy link
Copy Markdown
Contributor Author

Ok, i think i have made it succesfully.

@bedevere-app

bedevere-app Bot commented Jan 20, 2026

Copy link
Copy Markdown

GH-144078 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jan 20, 2026
sobolevn added a commit that referenced this pull request Jan 20, 2026
… methods in tests (GH-143870) (#144078)

(cherry picked from commit cb6a662)

Co-authored-by: sobolevn <mail@sobolevn.me>
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
…methods in tests (python#143870)

Co-authored-by: sobolevn <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing return value validation in pathlib's write_text and write_bytes tests

3 participants