Skip to content

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

Description

@bluetech

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

Activity

nineteendo commented on May 17, 2024

@nineteendo
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.

added 2 commits that reference this issue on May 17, 2024
added a commit that references this issue on May 19, 2024
added a commit that references this issue on May 19, 2024

barneygale commented on May 19, 2024

@barneygale
Contributor

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

added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions