Skip to content

Commit 11c5e31

Browse files
authored
Merge branch 'main' into main
2 parents 873d47e + 3c28510 commit 11c5e31

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/jit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ on:
55
- '**jit**'
66
- 'Python/bytecodes.c'
77
- 'Python/optimizer*.c'
8+
- '!Python/perf_jit_trampoline.c'
9+
- '!**/*.md'
10+
- '!**/*.ini'
811
push:
912
paths:
1013
- '**jit**'
1114
- 'Python/bytecodes.c'
1215
- 'Python/optimizer*.c'
16+
- '!Python/perf_jit_trampoline.c'
17+
- '!**/*.md'
18+
- '!**/*.ini'
1319
workflow_dispatch:
1420

1521
permissions:

Lib/pathlib/_abc.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,13 @@ def with_suffix(self, suffix):
205205
string, remove the suffix from the path.
206206
"""
207207
stem = self.stem
208-
if not suffix:
209-
return self.with_name(stem)
210-
elif not stem:
208+
if not stem:
211209
# If the stem is empty, we can't make the suffix non-empty.
212210
raise ValueError(f"{self!r} has an empty name")
213-
elif suffix.startswith('.') and len(suffix) > 1:
214-
return self.with_name(stem + suffix)
215-
else:
211+
elif suffix and not (suffix.startswith('.') and len(suffix) > 1):
216212
raise ValueError(f"Invalid suffix {suffix!r}")
213+
else:
214+
return self.with_name(stem + suffix)
217215

218216
def relative_to(self, other, *, walk_up=False):
219217
"""Return the relative path to another path identified by the passed

Lib/test/test_pathlib/test_pathlib_abc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,14 +999,15 @@ def test_with_suffix_windows(self):
999999
self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c\\d')
10001000
self.assertRaises(ValueError, P('c:a/b').with_suffix, '.c/d')
10011001
self.assertRaises(ValueError, P('c:a/b').with_suffix, '.c\\d')
1002+
self.assertRaises(TypeError, P('c:a/b').with_suffix, None)
10021003

10031004
def test_with_suffix_empty(self):
10041005
P = self.cls
10051006
# Path doesn't have a "filename" component.
10061007
self.assertRaises(ValueError, P('').with_suffix, '.gz')
10071008
self.assertRaises(ValueError, P('/').with_suffix, '.gz')
10081009

1009-
def test_with_suffix_seps(self):
1010+
def test_with_suffix_invalid(self):
10101011
P = self.cls
10111012
# Invalid suffix.
10121013
self.assertRaises(ValueError, P('a/b').with_suffix, 'gz')
@@ -1017,6 +1018,7 @@ def test_with_suffix_seps(self):
10171018
self.assertRaises(ValueError, P('a/b').with_suffix, '.c/.d')
10181019
self.assertRaises(ValueError, P('a/b').with_suffix, './.d')
10191020
self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.')
1021+
self.assertRaises(TypeError, P('a/b').with_suffix, None)
10201022

10211023
def test_relative_to_common(self):
10221024
P = self.cls

Lib/test/test_posixpath.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ def test_realpath_resolve_first(self):
663663
@os_helper.skip_unless_symlink
664664
@skip_if_ABSTFN_contains_backslash
665665
@unittest.skipIf(os.chmod not in os.supports_follow_symlinks, "Can't set symlink permissions")
666+
@unittest.skipIf(sys.platform != "darwin", "only macOS requires read permission to readlink()")
666667
def test_realpath_unreadable_symlink(self):
667668
try:
668669
os.symlink(ABSTFN+"1", ABSTFN)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix issue where :meth:`pathlib.PurePath.with_suffix` didn't raise
2+
:exc:`TypeError` when given ``None`` as a suffix.

0 commit comments

Comments
 (0)