This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python for Windows 2.7.7: Path Configuration File No Longer Works With UNC Paths
Type: behavior Stage: resolved
Components: Windows Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Matt.Mackall, benjamin.peterson, eryksun, jblairpdx, python-dev
Priority: release blocker Keywords:

Created on 2014-06-05 18:54 by jblairpdx, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg219833 - (view) Author: Jacob Blair (jblairpdx) Date: 2014-06-05 18:54
I just upgraded from 2.7.6 to 2.7.7, on Windows, and have encountered different behavior in my path configuration (.pth) files. One of my files had lines similar to these:

\\host\sharefolder

These paths (UNC-style), are not being loaded into sys.path. It is successfully loading path lines from this and other files, so long as they have a drive letter.
msg219850 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2014-06-05 21:27
site.addpackage calls site.makepath(sitedir, line): 

    def makepath(*paths):
        dir = os.path.join(*paths)
        try:
            dir = os.path.abspath(dir)
        except OSError:
            pass
        return dir, os.path.normcase(dir)

In 2.7.7, os.path.join gets this wrong. For example:

    >>> print os.path.join(r'C:\Spam\Eggs', r'\\Eggs\Spam')
    C:\\Eggs\Spam

3.4 gets it right:

    >>> print(os.path.join(r'C:\Spam\Eggs', r'\\Eggs\Spam'))
    \\Eggs\Spam

ntpath.join was reimplemented for issue 19456. The rewrite depends on ntpath.splitdrive, but 2.x has the old splitdrive that doesn't handle UNC paths:

    >>> os.path.splitdrive(r'\\Spam\Eggs')
    ('', '\\\\Spam\\Eggs')

Instead there's ntpath.splitunc (deprecated in 3.1+):

    >>> os.path.splitunc(r'\\Spam\Eggs')  
    ('\\\\Spam\\Eggs', '')

Maybe ntpath.join could also try splitunc, or maybe 3.x splitdrive can be backported.

2.7.7 ntpath.join:
http://hg.python.org/cpython/file/f89216059edf/Lib/ntpath.py#l61
msg221334 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-23 02:11
New changeset 26ec6248ee8b by Benjamin Peterson in branch '2.7':
fix ntpath.join on UNC-style paths by backporting py3k's splitdrive (closes #21672)
http://hg.python.org/cpython/rev/26ec6248ee8b
msg237202 - (view) Author: Matt Mackall (Matt.Mackall) Date: 2015-03-04 19:23
Changeset 26ec62 regressed Mercurial.

http://bz.selenic.com/show_bug.cgi?id=4557

Before:

>>> ntpath.join(r'\\foo\bar\baz', '')
'\\\\foo\\bar\\baz\\'
>>> ntpath.join(r'\\foo\bar', '')
'\\\\foo\\bar\\'

After:

>>> ntpath.join(r'\\foo\bar\baz', '')
'\\\\foo\\bar\\baz\\'
>>> ntpath.join(r'\\foo\bar', '')
'\\\\foo\\bar'
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65871
2015-03-04 19:23:54Matt.Mackallsetnosy: + Matt.Mackall
messages: + msg237202
2014-06-23 02:11:05python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg221334

resolution: fixed
stage: needs patch -> resolved
2014-06-23 01:35:29ned.deilysetpriority: normal -> release blocker
nosy: + benjamin.peterson

stage: needs patch
2014-06-05 21:27:38eryksunsetnosy: + eryksun
messages: + msg219850
2014-06-05 19:12:25serhiy.storchakasettype: behavior
components: + Windows
2014-06-05 18:54:39jblairpdxcreate