Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ def tweak_readme(tag: Tag, filename: str = "README.rst") -> None:
print(f"Updating {filename}...", end=" ")
readme = Path(filename)

# Update first line: "This is Python version 3.14.0 alpha 7"
# Update first line: "This is Python version X.Y.Z {release_level} N"
# and update length of underline in second line to match.
lines = readme.read_text().splitlines()
lines = readme.read_text(encoding="utf-8").split("\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lines = readme.read_text(encoding="utf-8").split("\n")
lines = readme.read_text().split("\n")

I think we can skip this, we have a platform check:

release-tools/run_release.py

Lines 1375 to 1384 in a8981b1

if sys.platform not in ("darwin", "linux"):
print(
"""\
WARNING! This script has not been tested on a platform other than Linux and macOS.
Although it should work correctly as long as you have all the dependencies,
some things may not work as expected. As a release manager, you should try to
fix these things in this script so it also supports your platform.
"""
)

And there's no RM using Windows now, or next. Perhaps the next one after Savannah will in 2028, but we can deal with it then (along with likely other Windows incompatibilities), and we might be using 3.15 as the minimum by then, with UTF-8 as default.

this_is = f"This is Python version {tag.long_name}"
underline = "=" * len(this_is)
lines[0] = this_is
Expand Down
9 changes: 6 additions & 3 deletions tests/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ def test_tweak_readme(
tag = release.Tag(test_tag)

original_readme_file = Path(__file__).parent / "README.rst"
original_contents = original_readme_file.read_text()
original_contents = original_readme_file.read_text(encoding="utf-8")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
original_contents = original_readme_file.read_text(encoding="utf-8")
original_contents = original_readme_file.read_text()

readme_file = tmp_path / "README.rst"
readme_file.write_text(original_contents)

# Act
release.tweak_readme(tag, filename=str(readme_file))

# Assert
original_lines = original_contents.splitlines()
new_lines = readme_file.read_text().splitlines()
original_lines = original_contents.split("\n")
new_contents = readme_file.read_text(encoding="utf-8")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new_contents = readme_file.read_text(encoding="utf-8")
new_contents = readme_file.read_text()

new_lines = new_contents.split("\n")
assert new_lines[0] == expected_version
assert new_lines[1] == expected_underline
assert new_lines[2:] == original_lines[2:]
assert original_contents.endswith("\n")
assert new_contents.endswith("\n")