◐ Shell
clean mode source ↗

GH-110109: Add `pathlib._PurePathBase` by barneygale · Pull Request #110670 · python/cpython

Add private `pathlib._PurePathBase` class: a private superclass of both
`PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of
these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`,
`__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`.

This is important for supporting *virtual paths*: user subclasses of
`_PathBase` that provide access to archive files, FTP servers, etc. In
these classes, the above methods should be implemented by users only as
appropriate, with due consideration for the hash/equality of any backing
objects, such as file objects or sockets.

@barneygale

aisk pushed a commit to aisk/cpython that referenced this pull request

Feb 11, 2024
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly.

This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.

Glyphack pushed a commit to Glyphack/cpython that referenced this pull request

Sep 2, 2024
Add private `pathlib._PurePathBase` class: a private superclass of both `PurePath` and `_PathBase`. Unlike `PurePath`, it does not define any of these special methods: `__fspath__`, `__bytes__`, `__reduce__`, `__hash__`, `__eq__`, `__lt__`, `__le__`, `__gt__`, `__ge__`. Its initializer and path joining methods accept only strings, not os.PathLike objects more broadly.

This is important for supporting *virtual paths*: user subclasses of `_PathBase` that provide access to archive files, FTP servers, etc. In these classes, the above methods should be implemented by users only as appropriate, with due consideration for the hash/equality of any backing objects, such as file objects or sockets.