You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pathlib.Path.with_suffix(None) became allowed in Python 3.13b1 #119113
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".
Activity
nineteendo commentedon May 17, 2024
Bisected to 19a1fc1
cpython/Lib/pathlib/_abc.py
Line 208 in 100c7ab
I guess we could replace that with this:
But we usually don't go out of our way to raise type errors.
pythonGH-119113: Raise `TypeError` on `pathlib.PurePath.with_suffix(N…
GH-119113: Raise `TypeError` from `pathlib.PurePath.with_suffix(None)` (
pythonGH-119113: Raise `TypeError` from `pathlib.PurePath.with_suffix…
[3.13] GH-119113: Raise `TypeError` from `pathlib.PurePath.with_suffi…
barneygale commentedon May 19, 2024
Thanks for reporting! Should be fixed in 3.13 beta 2.
pythonGH-119113: Raise `TypeError` from `pathlib.PurePath.with_suffix…