cpython/Lib/test/test_pathlib/support
Barney Gale 805e3368d6
GH-128520: pathlib ABCs: improve protocol for 'openable' objects (#134101)
Rename `pathlib._os.magic_open()` to `vfsopen()`. The new name is a bit
less abstract, and it aligns with the `vfspath()` method added in 5dbd27d.

Per discussion on discourse[^1], adjust `vfsopen()` so that the following
methods may be called:

- `__open_reader__()`
- `__open_writer__(mode)`
- `__open_updater__(mode)`

These three methods return readable, writable, and full duplex file objects
respectively. In the 'writer' method, *mode* is either 'a', 'w' or 'x'. In
the 'updater' method, *mode* is either 'r' or 'w'.

In the pathlib ABCs, replace `ReadablePath.__open_rb__()` with
`__open_reader__()`, and replace `WritablePath.__open_wb__()` with
`__open_writer__()`.

[^1]: https://discuss.python.org/t/open-able-objects/90238

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-09-12 22:25:18 +01:00
..
__init__.py GH-128520: pathlib ABCs: allow tests to be run externally (#131315) 2025-03-21 22:18:20 +00:00
lexical_path.py GH-128520: pathlib ABCs: add JoinablePath.__vfspath__() (#133437) 2025-05-12 19:00:36 +01:00
local_path.py GH-128520: pathlib ABCs: improve protocol for 'openable' objects (#134101) 2025-09-12 22:25:18 +01:00
zip_path.py GH-128520: pathlib ABCs: improve protocol for 'openable' objects (#134101) 2025-09-12 22:25:18 +01:00