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.Path.with_suffix(None) became allowed in Python 3.13b1 #119113

Closed
bluetech opened this issue May 17, 2024 · 2 comments
Closed

pathlib.Path.with_suffix(None) became allowed in Python 3.13b1 #119113

bluetech opened this issue May 17, 2024 · 2 comments
Labels
3.13 bugs and security fixes topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@bluetech
Copy link

bluetech commented May 17, 2024

Bug report

Bug description:

In Python 3.13b1 (compared to Python 3.12 and earlier), the behavior of pathlib.Path.with_suffix(None) changed from raising an incidental TypeError to removing the suffix. This casues a certain test in pytest to fail. I am going to fix pytest to not rely on this in any case, but I think pathlib should either:

  • Restore the previous behavior if it was unintended, or
  • Update the doc that None is now accepted. Currently it says " If the suffix is an empty string, the original suffix is removed".

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux

Linked PRs

@bluetech bluetech added the type-bug An unexpected behavior, bug, or error label May 17, 2024
@aisk aisk added topic-pathlib 3.13 bugs and security fixes labels May 17, 2024
@nineteendo
Copy link
Contributor

Bisected to 19a1fc1

if not suffix:

I guess we could replace that with this:

if suffix == '':

But we usually don't go out of our way to raise type errors.

barneygale added a commit to barneygale/cpython that referenced this issue May 17, 2024
…one)`

Restore behaviour from 3.12 when `path.with_suffix(None)` is called.
barneygale added a commit that referenced this issue May 19, 2024
#119124)

Restore behaviour from 3.12 when `path.with_suffix(None)` is called.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 19, 2024
…(None)` (pythonGH-119124)

Restore behaviour from 3.12 when `path.with_suffix(None)` is called.
(cherry picked from commit 3c28510)

Co-authored-by: Barney Gale <[email protected]>
barneygale added a commit that referenced this issue May 19, 2024
…x(None)` (GH-119124) (#119183)

Restore behaviour from 3.12 when `path.with_suffix(None)` is called.
(cherry picked from commit 3c28510)

Co-authored-by: Barney Gale <[email protected]>
@barneygale
Copy link
Contributor

Thanks for reporting! Should be fixed in 3.13 beta 2.

estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…(None)` (python#119124)

Restore behaviour from 3.12 when `path.with_suffix(None)` is called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-pathlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants