This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients AlexWaygood, barneygale, eric.araujo, eryksun, pitrou, serhiy.storchaka, terry.reedy
Date 2022-02-21.11:42:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645443765.4.0.715292042354.issue46733@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2022-02-21 11:42:45eryksunsetrecipients: + eryksun, terry.reedy, pitrou, eric.araujo, serhiy.storchaka, barneygale, AlexWaygood
2022-02-21 11:42:45eryksunsetmessageid: <1645443765.4.0.715292042354.issue46733@roundup.psfhosted.org>
2022-02-21 11:42:45eryksunlinkissue46733 messages
2022-02-21 11:42:45eryksuncreate