Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python for Windows 2.7.7: Path Configuration File No Longer Works With UNC Paths #65871

Closed
jblairpdx mannequin opened this issue Jun 5, 2014 · 4 comments
Closed

Python for Windows 2.7.7: Path Configuration File No Longer Works With UNC Paths #65871

jblairpdx mannequin opened this issue Jun 5, 2014 · 4 comments
Labels
OS-windows release-blocker type-bug An unexpected behavior, bug, or error

Comments

@jblairpdx
Copy link
Mannequin

jblairpdx mannequin commented Jun 5, 2014

BPO 21672
Nosy @benjaminp, @eryksun, @jblairpdx

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-06-23.02:11:05.029>
created_at = <Date 2014-06-05.18:54:39.282>
labels = ['type-bug', 'OS-windows', 'release-blocker']
title = 'Python for Windows 2.7.7: Path Configuration File No Longer Works With UNC Paths'
updated_at = <Date 2015-03-04.19:23:54.384>
user = 'https://github.com/jblairpdx'

bugs.python.org fields:

activity = <Date 2015-03-04.19:23:54.384>
actor = 'Matt.Mackall'
assignee = 'none'
closed = True
closed_date = <Date 2014-06-23.02:11:05.029>
closer = 'python-dev'
components = ['Windows']
creation = <Date 2014-06-05.18:54:39.282>
creator = 'jblairpdx'
dependencies = []
files = []
hgrepos = []
issue_num = 21672
keywords = []
message_count = 4.0
messages = ['219833', '219850', '221334', '237202']
nosy_count = 5.0
nosy_names = ['benjamin.peterson', 'python-dev', 'Matt.Mackall', 'eryksun', 'jblairpdx']
pr_nums = []
priority = 'release blocker'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue21672'
versions = ['Python 2.7']

@jblairpdx
Copy link
Mannequin Author

jblairpdx mannequin commented Jun 5, 2014

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.

@serhiy-storchaka serhiy-storchaka added OS-windows type-bug An unexpected behavior, bug, or error labels Jun 5, 2014
@eryksun
Copy link
Contributor

eryksun commented Jun 5, 2014

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

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jun 23, 2014

New changeset 26ec6248ee8b by Benjamin Peterson in branch '2.7':
fix ntpath.join on UNC-style paths by backporting py3k's splitdrive (closes bpo-21672)
http://hg.python.org/cpython/rev/26ec6248ee8b

@python-dev python-dev mannequin closed this as completed Jun 23, 2014
@MattMackall
Copy link
Mannequin

MattMackall mannequin commented Mar 4, 2015

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'

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows release-blocker type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants