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.

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
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:


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)
            dir = os.path.abspath(dir)
        except OSError:
        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')

3.4 gets it right:

    >>> print(os.path.join(r'C:\Spam\Eggs', r'\\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:
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)
msg237202 - (view) Author: Matt Mackall (Matt.Mackall) Date: 2015-03-04 19:23
Changeset 26ec62 regressed Mercurial.


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


>>> ntpath.join(r'\\foo\bar\baz', '')
>>> ntpath.join(r'\\foo\bar', '')
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