Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathlib.PurePath.with_stem('') promotes file extension to stem #114610

Closed
barneygale opened this issue Jan 26, 2024 · 0 comments
Closed

pathlib.PurePath.with_stem('') promotes file extension to stem #114610

barneygale opened this issue Jan 26, 2024 · 0 comments
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@barneygale
Copy link
Contributor

barneygale commented Jan 26, 2024

Bug report

>>> pathlib.PurePath('foo.jpg').with_stem('').stem
'.jpg'

The with_stem() call should raise ValueError, as it's impossible for a filename to have an empty stem and a non-empty suffix.

Linked PRs

@barneygale barneygale added type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.12 bugs and security fixes topic-pathlib 3.13 new features, bugs and security fixes labels Jan 26, 2024
barneygale added a commit to barneygale/cpython that referenced this issue Jan 26, 2024
…e extensions

Raise `ValueError` if `with_stem('')` is called on a path with a file
extension. Paths may only have an empty stem if they also have an empty
suffix.
barneygale added a commit to barneygale/cpython that referenced this issue Jan 26, 2024
…handling of stems

Raise `ValueError` if `with_suffix('.ext')` is called on a path without a
stem. Paths may only have a non-empty suffix if they also have a non-empty
stem.

ABC-only bugfix; no effect on public classes.
barneygale added a commit to barneygale/cpython that referenced this issue Jan 28, 2024
barneygale added a commit to barneygale/cpython that referenced this issue Jan 30, 2024
barneygale added a commit that referenced this issue Jan 30, 2024
…ng of stems (#114613)

Raise `ValueError` if `with_suffix('.ext')` is called on a path without a
stem. Paths may only have a non-empty suffix if they also have a non-empty
stem.

ABC-only bugfix; no effect on public classes.
barneygale added a commit to barneygale/cpython that referenced this issue Jan 30, 2024
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…handling of stems (python#114613)

Raise `ValueError` if `with_suffix('.ext')` is called on a path without a
stem. Paths may only have a non-empty suffix if they also have a non-empty
stem.

ABC-only bugfix; no effect on public classes.
barneygale added a commit that referenced this issue Feb 24, 2024
…nsions (#114612)

Raise `ValueError` if `with_stem('')` is called on a path with a file
extension. Paths may only have an empty stem if they also have an empty
suffix.
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
…e extensions (python#114612)

Raise `ValueError` if `with_stem('')` is called on a path with a file
extension. Paths may only have an empty stem if they also have an empty
suffix.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…e extensions (python#114612)

Raise `ValueError` if `with_stem('')` is called on a path with a file
extension. Paths may only have an empty stem if they also have an empty
suffix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes topic-pathlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant