| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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.
|
FYI @AlexWaygood. We avoided adding this class previously with your clever suggestion to set __fspath__ and __bytes__ to None in PathBase, and then restore their values in Path. (see #106082, #106337). But I'm increasingly convinced that this extra class is needed after all - there are too many PurePath magic methods which shouldn't be inherited by PathBase. Hence this PR adds a new superclass. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Quite a lot of this patch is re-ordering methods. I've split that stuff off into a preparatory PR, which will help make this PR easier to review: |
Sorry, something went wrong.
|
Once this lands, I plan to:
It's going to be a while before PurePathBase sees official public release in CPython, so I reckon we don't need to get its interface perfect in this PR. Hopefully that makes it less intimidating to review. |
Sorry, something went wrong.
|
Given that this change is blocking work on pathlib ABCs, and should have no observable effects on any public APIs, I'm going to merge it without waiting any longer for review. If that doesn't seem right to anyone, please let me know and I can revert it. I'm never quite sure where to draw the line on these things. |
Sorry, something went wrong.
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.
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.
| Back | FazBrowse Home | New Git URL |
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.