[Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-11 Thread Isaac Schwabacher
I see this as a parallel to the question of `pathlib.PurePath.resolve()`, about which `pathlib` is (rightly!) very opinionated. Just as `foo/../bar` shouldn't resolve to `bar`, `foo/` shouldn't be truncated to `foo`. And if `PurePath` doesn't do this, `Path` shouldn't either, because the differe

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-08 Thread Alexander Belopolsky
On Fri, Aug 8, 2014 at 8:27 AM, Paul Moore wrote: > I had a use case where I wanted to allow a config file to contain > "path: foo" to create a file called foo, and "path: foo/" to create a > directory. It was a shortcut for specifying an explicit "directory: > true" parameter as well. > Here is

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-08 Thread Paul Moore
On 7 August 2014 02:55, Antoine Pitrou wrote: > pathlib is generally concerned with filesystem operations written in Python, > not arbitrary third-party tools. Also it is probably easy to append the > trailing slash in your command-line invocation, if so desired. I had a use case where I wanted t

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-07 Thread Guido van Rossum
Hm. I personally consider a trailing slash significant. It feels semantically different (and in some cases it is) so I don't think it should be normalized. The behavior of os.path.split() here feels right. On Wed, Aug 6, 2014 at 7:30 PM, Antoine Pitrou wrote: > > Le 06/08/2014 22:12, Ben Finney

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-06 Thread Antoine Pitrou
Le 06/08/2014 22:12, Ben Finney a écrit : You seem to be saying that ‘pathlib’ is not intended to be helpful for constructing a shell command. pathlib lets you do operations on paths. It also gives you a string representation of the path that's expected to designate that path when talking to

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-06 Thread Ben Finney
Antoine Pitrou writes: > Le 06/08/2014 20:50, Alexander Belopolsky a écrit : > > There are many interfaces where trailing slash is significant. […] > > Loosing it when passing path strings through pathlib.Path() may be a > > source of bugs. > > pathlib is generally concerned with filesystem opera

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-06 Thread Antoine Pitrou
Le 06/08/2014 20:50, Alexander Belopolsky a écrit : On Wed, Aug 6, 2014 at 8:11 PM, Antoine Pitrou mailto:anto...@python.org>> wrote: Am I overlooking other cases? There are many interfaces where trailing slash is significant. For example, rsync uses trailing slash on the target directory

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-06 Thread Alexander Belopolsky
On Wed, Aug 6, 2014 at 8:11 PM, Antoine Pitrou wrote: > Am I overlooking other cases? There are many interfaces where trailing slash is significant. For example, rsync uses trailing slash on the target directory to avoid creating an additional directory level at the destination. Loosing it wh

Re: [Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-06 Thread Antoine Pitrou
Le 06/08/2014 18:36, Isaac Schwabacher a écrit : If a symbolic link is encountered during pathname resolution, the behavior shall depend on whether the pathname component is at the end of the pathname and on the function being performed. If all of the following are true, then pathname resolutio

[Python-Dev] pathlib handling of trailing slash (Issue #21039)

2014-08-06 Thread Isaac Schwabacher
pathlib.Path currently strips trailing slashes from pathnames, but this behavior contradicts POSIX (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12), which specifies that the resolution of the pathname of a symbolic link to a directory in the context of a funct