And I’d expect __fspath__ () to be called if it exists. This has been recently implemented in several tools like nox, but is there a reason subprocess.run and family can’t support it too? os.fspath already passes strings through, though you can also just check to see if it’s an instance of os.PathLike / has a __fspath__ method first instead.
Most other places paths are accepted in Python have been updated to support the fspath protocol, but this seems like a missing one.
I looked for “pathlike”/“fspath” and “subprocess” together, but didn’t see a past discussion.
Ahh, that’s embarrassing, I have seen this on a CI matrix and could have sworn it was still broken on newer Pythons, but I don’t usually run Windows locally to test it. I forget to mention, it was Windows only - 3.7 accidentally supported Path on UNIX, but produced a “TypeError: argument of type ‘WindowsPath’ is not iterable” on Windows. I’ve verified this fails on 3.7 on Windows only, and works on 3.8 and 3.9 on Windows. Thanks! “It already works” is the best sort of answer. Sorry for the confusion.
(This also explains why it hasn’t come up before!)