[issue1209447] os.path.join() fails if 2nd arg is a UNC path

Pekka Klärck report at bugs.python.org
Wed Dec 5 15:58:42 CET 2012


Pekka Klärck added the comment:

It seems that joining UNC path to a directory root fails:

Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ntpath import join
>>> join('c:\\', '\\\\server\\mount\\dir')
'c:\\\\server\\mount\\dir'

When the first argument contains also something else everything works fine:

>>> join('c:\\dir', '\\\\server\\mount\\dir')
'\\\\server\\mount\\dir'

I would say this is a bug. Obviously fixing this changes behavior, but I have hard time believing that anyone relies on the current buggy output.

On the other hand, I was today reported a bug in my software that was caused by this. Funny thing was that the bug was in code that was added as a workaround for issue #3426 (i.e. use `join(os.getcwdu(), path)` instead of `abspath(path)` when path is Unicode). Luckily adding another workaround for this issue is pretty easy.

----------
nosy: +pekka.klarck

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1209447>
_______________________________________


More information about the Python-bugs-list mailing list