Message413647
> pathlib does not allow to distinguish "path" from "path/".
os.path.normpath() and os.path.abspath() don't retain a trailing slash -- or a leading dot component for that matter. Are you referring to os.path.join()? For example:
>>> os.path.join('./spam', 'eggs/')
'./spam/eggs/'
>>> os.path.normpath('./spam/eggs/')
'spam/eggs'
>>> PurePath('./spam') / PurePath('eggs/')
PurePosixPath('spam/eggs')
A leading dot component is significant in a context that searches a set of paths -- usually PATH. A trailing slash is significant in a context that has to distinguish a device or file path from a directory path, of which there are several cases in Windows.
I think it's a deficiency in pathlib that it lacks a way to require conservative normalization in these cases. Path and PurePath objects could gain a keyword-only parameter, and internal attribute if needed, that enables a more conservative normalization. |
|
Date |
User |
Action |
Args |
2022-02-21 11:42:45 | eryksun | set | recipients:
+ eryksun, terry.reedy, pitrou, eric.araujo, serhiy.storchaka, barneygale, AlexWaygood |
2022-02-21 11:42:45 | eryksun | set | messageid: <1645443765.4.0.715292042354.issue46733@roundup.psfhosted.org> |
2022-02-21 11:42:45 | eryksun | link | issue46733 messages |
2022-02-21 11:42:45 | eryksun | create | |
|