Return a new path with the stem changed.
(self, stem)
| 417 | return self._from_parsed_parts(self.drive, self.root, tail) |
| 418 | |
| 419 | def with_stem(self, stem): |
| 420 | """Return a new path with the stem changed.""" |
| 421 | suffix = self.suffix |
| 422 | if not suffix: |
| 423 | return self.with_name(stem) |
| 424 | elif not stem: |
| 425 | # If the suffix is non-empty, we can't make the stem empty. |
| 426 | raise ValueError(f"{self!r} has a non-empty suffix") |
| 427 | else: |
| 428 | return self.with_name(stem + suffix) |
| 429 | |
| 430 | def with_suffix(self, suffix): |
| 431 | """Return a new path with the file suffix changed. If the path |