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
In #104996 I made pathlib defer joining of arguments given to path initialisers (like PurePath('a', 'b') and via joinpath(), __truediv__() and __rtruediv__().
This "optimisation" often results in more path joining. Consider:
Path modules provide a subset of the `os.path` API, specifically those
functions needed to provide `PurePathBase` functionality. Each
`PurePathBase` subclass references its path module via a `pathmod` class
attribute.
This commit adds a new `PathModuleBase` class, which provides abstract
methods that unconditionally raise `UnsupportedOperation`. An instance of
this class is assigned to `PurePathBase.pathmod`, replacing `posixpath`.
As a result, `PurePathBase` is no longer POSIX-y by default, and almost[^1]
all its methods raise `UnsupportedOperation` courtesy of `pathmod`.
Users who subclass `PurePathBase` or `PathBase` should choose the path
syntax by setting `pathmod` to `posixpath`, `ntpath`, `os.path`, or their
own subclass of `PathModuleBase`, as circumstances demand.
[^1] Except `joinpath()`, `__truediv__()`, `__rtruediv__()`. See pythonGH-113888.
In #104996 I made pathlib defer joining of arguments given to path initialisers (like
PurePath('a', 'b')
and viajoinpath()
,__truediv__()
and__rtruediv__()
.This "optimisation" often results in more path joining. Consider:
(the
print()
could be any operation on the path object other than a further join)Under the hood this results in the following calls:
If we'd naively joined the paths, we'd instead have:
The text was updated successfully, but these errors were encountered: