[issue15342] os.path.join behavior

2012-07-21 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 61d0e3526a51 by R David Murray in branch '3.2':
#15342: Add clarifying sentence to posixpath.join docstring.
http://hg.python.org/cpython/rev/61d0e3526a51

New changeset 30d4d1528b58 by R David Murray in branch 'default':
Merge #15342: Add clarifying sentence to posixpath.join docstring.
http://hg.python.org/cpython/rev/30d4d1528b58

New changeset f3cc7626a621 by R David Murray in branch '2.7':
#15342: Add clarifying sentence to posixpath.join docstring.
http://hg.python.org/cpython/rev/f3cc7626a621

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15342] os.path.join behavior

2012-07-21 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I've added the sentence to the docstring, as you suggested.  Thanks for the 
suggestion.

--
versions: +Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15342] os.path.join behavior

2012-07-15 Thread Yongzhi Pan

Yongzhi Pan fossi...@users.sourceforge.net added the comment:

I suggest append An empty last part will result in a path that ends with a 
separator or something similar to the docstring, though it is already in the 
HTML documentation. 

Suppose someone does this like me:

In [10]: join('a', sep)
Out[10]: '/'

He must be surprised. He has to guess how to append a separator if he does not 
look at the code, or fiddle around until he finds the soultion. 

Given it explained in the docstring, after he sees:

In [10]: join('a', sep)
Out[10]: '/'

He will probably look at the docstring:

In [16]: join?
Type:   function
Base Class: type 'function'
String Form:function join at 0x7f053fc93ed8
Namespace:  Interactive
File:   /usr/lib/python2.7/posixpath.py
Definition: join(a, *p)
Docstring:
Join two or more pathname components, inserting '/' as needed.
If any component is an absolute path, all previous path components
will be discarded. An empty last part will result in a path that
ends with a separator.

Ok, he immediately knows he has to supply an empty string instead of a 
separator.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15342] os.path.join behavior

2012-07-13 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

os.path.join is working as documented. See 
http://docs.python.org/library/os.path.html#os.path.join

If any component is an absolute path, all previous components (on Windows, 
including the previous drive letter, if there was one) are thrown away, and 
joining continues. ... This means that an empty last part will result in a 
path that ends with a separator.  So, to have the path end with a separator, 
use an empty string rather than '/' as the last component.

 import os
 os.path.join('/','Users', 'nad')
'/Users/nad'
 os.path.join('/','Users', 'nad', '')
'/Users/nad/'

--
nosy: +ned.deily
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15342] os.path.join behavior

2012-07-13 Thread Pan Yongzhi

Pan Yongzhi fossi...@users.sourceforge.net added the comment:

I know this is working as documented. But working as documented does not mean 
it is not a bug.

I cannot deduce that it will append a separator if joining with an empty string 
from the documentation. Also, this behavior is implicit, and have to guess. 
Either the document or the behaivor have to be changed.

I think it is not only me:

http://stackoverflow.com/questions/1945920/os-path-join-python

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15342] os.path.join behavior

2012-07-13 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Whatever the good or bad points of the API design, it is what it is and has 
been for a very long time.  It is not something that is going to change, 
because the break in backward compatibility would be too large.

What is unclear about the documentation that Ned quoted (This means that an 
empty last part will result in a path that ends with a separator.)?  How would 
you suggest improving the documentation?

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15342] os.path.join behavior

2012-07-12 Thread Pan Yongzhi

New submission from Pan Yongzhi fossi...@users.sourceforge.net:

I am constructing a source directory argument to rsync. It has to end with 
slash due to rsync behavior. I use:

os.path.join('/src/dir', os.path.sep)

And run it and realized the source directory becomes '/'. Luckily it is not the 
destination.

Why should join discard all previous path components if any component is an 
absoulute path? This is such a surprise and renders this function useless.

--
messages: 165348
nosy: fossilet
priority: normal
severity: normal
status: open
title: os.path.join behavior
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15342
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com