Madison May added the comment:

So the problem arises because a path to a file (not a path to a directory) is 
passed as an argument to start. So the way I see it, we could go one of several 
directions: 

1) We could check for the presence of an extension in the start argument, and 
truncate start_path to start_path[:-1] if an extension is found.  This wouldn't 
deal with the case where a path to a file without an extension is passed to 
relpath(), but it would deal with the large majority of cases.  I'm in favor of 
this option. 

2) We could add a warning to the docs and let users know that paths to files 
shouldn't be passed as the 'start' argument to relpath() -- only paths to 
directories are valid.  You could perhaps even raise an error when a path to a 
file with an extension is passed as the 'start' argument.

I've attached a patch for posixpath.py and ntpath.py with the first option in 
mind.  The patch also contains an test case for this behavior.

----------
nosy: +madison.may

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18389>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to