Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-89812: Add pathlib.UnsupportedOperation #105926

Merged
merged 3 commits into from
Jun 22, 2023

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Jun 19, 2023

This new exception type is raised instead of NotImplementedError when a path operation is not supported. It can be raised from Path.readlink(), symlink_to(), hardlink_to(), owner() and group(). In a future version of pathlib, it will be raised by AbstractPath for these methods and others, such as AbstractPath.mkdir() and unlink().


📚 Documentation preview 📚: https://cpython-previews--105926.org.readthedocs.build/

This new exception type is raised instead of `NotImplementedError` when
a path operation is not supported. It can be raised from `Path.readlink()`,
`symlink_to()`, `hardlink_to()`, `owner()` and `group()`. In a future
version of pathlib, it will be raised by `AbstractPath` for these methods
and others, such as `AbstractPath.mkdir()` and `unlink()`.
@barneygale barneygale changed the title GH-89812: Add pathlib.UnsupportedOperation GH-89812: Add pathlib.UnsupportedOperation Jun 19, 2023
@barneygale barneygale requested a review from encukou June 19, 2023 22:16
@encukou
Copy link
Member

encukou commented Jun 21, 2023

Looks good, thank you!

I'd add versionadded notes to the docs of all the functions, since we can't expect readers to check the docs for UnsupportedOperation.

@barneygale
Copy link
Contributor Author

Good shout, thank you. I've done it via .. versionchanged directives on each method - does it look OK?

Copy link
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@barneygale
Copy link
Contributor Author

Thanks very much for the idea and review!

@barneygale barneygale merged commit a800670 into python:main Jun 22, 2023
18 checks passed
bentasker pushed a commit to bentasker/cpython that referenced this pull request Jun 23, 2023
This new exception type is raised instead of `NotImplementedError` when
a path operation is not supported. It can be raised from `Path.readlink()`,
`symlink_to()`, `hardlink_to()`, `owner()` and `group()`. In a future
version of pathlib, it will be raised by `AbstractPath` for these methods
and others, such as `AbstractPath.mkdir()` and `unlink()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants