Eryk Sun <eryk...@gmail.com> added the comment:

> 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.

----------

_______________________________________
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