The only design flaw mentioned in that thread is that `os.path.expanduser()` returns the input unchanged if expansion fails, which is not very pythonic. However, such a problem doesn't necessitate a rewrite of `os.path.expanduser()`. Checking `result[:1]` is enough.
I think there's also a difference in the Windows heuristic in that pathlib checks whether `basename(%HOMEPATH%) == %USERNAME%` whereas `ntpath.expanduser` doesn't. But if that's really an issue it should probably be fixed in `ntpath` IMO, rather than having divergent implementations. |