[Python-bugs-list] [ python-Bugs-478425 ] Change in os.path.join (ntpath.py)

noreply@sourceforge.net noreply@sourceforge.net
Mon, 05 Nov 2001 13:31:23 -0800


Bugs item #478425, was opened at 2001-11-05 12:19
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478425&group_id=5470

Category: Python Library
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Greg Chapman (glchapman)
>Assigned to: Tim Peters (tim_one)
Summary: Change in os.path.join (ntpath.py)

Initial Comment:
I had been using this:

  os.path.join(dirname, "")

as a convenient way of getting a dirname with a path 
separator appended if it didn't have one already.  
Under Python 2.2b1 in Windows, this no longer works.  
Looking at the documentation (specifically, the 
qualifier "unless path is empty"), it appears that it 
never should have worked.  So, I guess that's not a 
bug.

However, in figuring this out, I noticed that the join 
in ntpath.py is now significantly different from the 
join in the other path modules.  And those other 
modules will still allow a blank string as the last 
parameter to produce a pathstring with a terminating 
path separator, so I guess they need to be updated.

Anyway, the different join behavior clearly needs to 
be synchronized between platforms.



----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2001-11-05 13:31

Message:
Logged In: YES 
user_id=31435

Ya, ntpath.join() became a friggin' mess after fixing a 
slew of bugs involving Windows "drive letters" (which other 
platforms can blissfully ignore).  I consider the new 
behavior in this case more of a bug than not, because 
ntpath.split('a\') produces ('a', ''), and it's best if 
join() acts like split()'s inverse (when possible).  So I 
restored the old behavior in this case:

Lib/ntpath.py; new revision: 1.44
Lib/test/test_ntpath.py; new revision: 1.13

Cases to note:

ntpath.join('') -> ''
ntpath.join('', '', '', '', '') -> ''
ntpath.join('a') -> 'a'
ntpath.join('', 'a') -> 'a
ntpath.join('', '', '', '', 'a') -> 'a'
ntpath.join('a', '') -> 'a\'
ntpath.join('a', '', '', '', '') -> 'a\'

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=478425&group_id=5470