Skip to content

Commit d15bb71

Browse files
Gate on 3.15+
1 parent dac266e commit d15bb71

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

release.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,13 @@ def tweak_patchlevel(
470470
"rc": "PY_RELEASE_LEVEL_GAMMA",
471471
"f": "PY_RELEASE_LEVEL_FINAL",
472472
}[tag.level]
473-
new_constants = template.format(
474-
tag=tag, level_def=level_def, plus=done and "+dev" or ""
475-
)
473+
if done:
474+
# 3.15+ uses "+dev" for PEP 440 local-version compliance; older
475+
# branches keep the bare "+" they were released with.
476+
plus = "+dev" if tag.as_tuple() >= (3, 15) else "+"
477+
else:
478+
plus = ""
479+
new_constants = template.format(tag=tag, level_def=level_def, plus=plus)
476480
if tag.as_tuple() >= (3, 7, 0, "a", 3):
477481
new_constants = new_constants.expandtabs()
478482
constant_replace(filename, new_constants)

tests/test_release.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,21 @@ def test_tweak_patchlevel(tmp_path: Path) -> None:
102102
assert expected in new_contents
103103

104104

105-
def test_tweak_patchlevel_done(tmp_path: Path) -> None:
105+
@pytest.mark.parametrize(
106+
["test_tag", "expected_py_version"],
107+
[
108+
# 3.14 and earlier keep the bare "+" they were released with.
109+
("3.14.0b2", '#define PY_VERSION "3.14.0b2+"'),
110+
# 3.15+ uses "+dev" for PEP 440 local-version compliance.
111+
("3.15.0b1", '#define PY_VERSION "3.15.0b1+dev"'),
112+
("3.16.0a1", '#define PY_VERSION "3.16.0a1+dev"'),
113+
],
114+
)
115+
def test_tweak_patchlevel_done(
116+
tmp_path: Path, test_tag: str, expected_py_version: str
117+
) -> None:
106118
# Arrange
107-
tag = release.Tag("3.14.0b2")
119+
tag = release.Tag(test_tag)
108120

109121
original_patchlevel_file = Path(__file__).parent / "patchlevel.h"
110122
patchlevel_file = tmp_path / "patchlevel.h"
@@ -115,7 +127,7 @@ def test_tweak_patchlevel_done(tmp_path: Path) -> None:
115127

116128
# Assert
117129
new_contents = patchlevel_file.read_text()
118-
assert '#define PY_VERSION "3.14.0b2+dev"' in new_contents
130+
assert expected_py_version in new_contents
119131

120132

121133
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)