[issue33426] Behavior of os.path.join does not match documentation

2018-05-04 Thread Michael Klatt

New submission from Michael Klatt :

The behavior of os.path.join() regarding path separators does not match the 
documentation. This affects Python 3.6, and goes back to at least Python 2.7.

>From the documenation: 

"The return value is the concatenation of path and any members of *paths with 
exactly one directory separator (os.sep) following each non-empty part except 
the last, meaning that the result will only end in a separator if the last part 
is empty."

To me, this means that join will remove extraneous separators from the path, 
and that the only way to produce a trailing separator is to use join "" as the 
final path segment.

I expect `os.path.join("/abc//", "def/")` to produce the string "/abc/def" 
based on the documentation, but what it actually produces is "abc//def/".

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 316184
nosy: Michael Klatt, docs@python
priority: normal
severity: normal
status: open
title: Behavior of os.path.join does not match documentation
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 
<https://bugs.python.org/issue33426>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33426] Behavior of os.path.join does not match documentation

2018-05-05 Thread Michael Klatt

Michael Klatt  added the comment:

For me, the ambiguity is due to the phrases "exactly one directory separator" 
and "the only way to produce a trailing separator".

I would suggest:

"The return value is the concatenation of path and any members of *paths so 
that there is a directory separator (os.sep) following each part except the 
last. An empty part is ignored unless it is the last part, in which case the 
result will end in a separator."

Or:

"The return value is the concatenation of path and any members of *paths such 
that there is guaranteed to be a directory separator (os.sep) following each 
part except the last. An empty part is ignored unless it is the last part, in 
which case the result will end in a separator."

--

___
Python tracker 
<https://bugs.python.org/issue33426>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com