New submission from Barney Gale <barney.g...@gmail.com>:

The docs for NotImplementedError say:

> In user defined base classes, abstract methods should raise this exception 
> when they require derived classes to override the method, or while the class 
> is being developed to indicate that the real implementation still needs to be 
> added.

pathlib's use of NotImplementedError appears to be more broad. It can be raised 
in the following circumstances:

1. When attempting to construct a WindowsPath from a non-Windows system, and 
vice-versa. This is the only case where NotImplementedError is mentioned in the 
pathlib docs (in a repl example)
2. In glob() and rglob() when an absolute path is supplied as a pattern
3. In owner() if the pwd module isn't available
4. In group() if the grp module isn't available
5. In readlink() if os.readlink() isn't available
6. In symlink_to() if os.symlink() isn't available
7. In hardlink_to() if os.hardlink() isn't available
8. In WindowsPath.is_mount(), unconditionally

I suspect there are better choices for exception types in all these cases.

----------
components: Library (Lib)
messages: 413142
nosy: barneygale
priority: normal
severity: normal
status: open
title: pathlib.Path methods can raise NotImplementedError
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46733>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to