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: pathlib does not support symlink in Windows XP
Type: behavior Stage:
Components: Library (Lib), Windows Versions: Python 3.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, brian.curtin, pitrou, steve.dower, tim.golden, vajrasky, zach.ware
Priority: normal Keywords: patch

Created on 2013-11-26 07:43 by vajrasky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
add_symlink_support_for_windows_xp.patch vajrasky, 2013-11-26 07:43 review
Messages (8)
msg204458 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-26 07:43
In Lib/pathlib.py, we got this "problematic" code:

     if sys.getwindowsversion()[:2] >= (6, 0):
         from nt import _getfinalpathname
     else:
         supports_symlinks = False
         _getfinalpathname = None

This code means if the windows version is less than Windows NT 6, then we disable symlink support.

http://en.wikipedia.org/wiki/Windows_NT_6.0

Windows NT 6.0 includes Vista, Server 2008. In other word, Windows XP is less than Windows NT 6.0.

Actually, we can add symbolic link support for Windows XP.
http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html#symboliclinksforwindowsxp

Attached the patch to add symbolic link support for Windows XP in pathlib.

Actually, if this ticket is made invalid, I don't care anyway. Windows XP will "die" on 8th April 2014.

http://windows.microsoft.com/en-us/windows/end-support-help

Also, how many people uses pathlib in Python 3.4 in Windows XP with third-party drivers enabling symbolic link support? Should be small.

I am interested in this problem because I have the same problem in Django.
https://code.djangoproject.com/ticket/21482
On the proposed pull request, I let the os.symlink takes care whether we have symbolic link support or not.

But I may "copy" Antoine's approach to Django's bug.
msg204530 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-26 20:33
> Also, how many people uses pathlib in Python 3.4 in Windows XP with
> third-party drivers enabling symbolic link support? Should be small.

I've never heard of third-party driver for symlink link support before (granted, I'm not a Windows user). I'm willing to bet that this is a niche situation indeed, so I'm not very warm for tweaking pathlib around it.
msg204552 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2013-11-27 05:18
If users want to do that hack to get symlinks on XP, they should probably just manage doing so on their own. It's not something we'd take care of installing and running via our installer, so I don't think pathlib should be changed to work for it.
msg204557 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-27 07:02
I agree we should not go "extra mile" to add feature for Windows XP, a 12 year old software and soon to be "put down" a couple months forward.

But in this case, Antoine goes "extra mile" to prevent symbolic link support in Windows XP. And it's not just him that has this kind of reasoning. Django developers put this code which is similar with pathlib.

django/contrib/staticfiles/management/commands/collectstatic.py

        if self.symlink:
            if sys.platform == 'win32':
                raise CommandError("Symlinking is not supported by this "
                                   "platform (%s)." % sys.platform)
            if not self.local:
                raise CommandError("Can't symlink to a remote destination.")

I opened this ticket because I am curious why developers go "extra mile" to prevent symbolic link support in certain platform. Why not just let os.symlink does the job and propagate the error from there? What is the virtue of not letting os.symlink decides who gets the symbolic link support? Surely in Windows XP (without 3rd party driver) os.symlink will throws exception and how that differs from throwing exception in pathlib library?

But anyway feel free to close this ticket. I think I'll just "copy" Antoine's checking in solving this Django's bug:
https://code.djangoproject.com/ticket/21482
msg204595 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2013-11-27 15:15
If a platform does not actually support symlinks, and XP does not actually support symlinks for any usual definition of an operating system supporting a feature, then I'm not sure why pathlib is doing something wrong to make it work more reasonably in that case.

"os.symlink" is a NotImplementedError on Windows versions prior to Vista because the Windows API doesn't support CreateSymbolicLink. It doesn't make sense to just let the code try to run for all versions on all platforms but be wrapped in a try/catch block for the NotImplementedError.
msg204597 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-27 15:18
The 2.7-compatible version of pathlib explains why the code is structured this way:

    if sys.getwindowsversion()[:2] >= (6, 0) and sys.version_info >= (3, 2):
        from nt import _getfinalpathname
    else:
        supports_symlinks = False
        _getfinalpathname = None


In the stdlib version, I removed the `sys.version_info >= (3, 2)` and so it may look like as easy to rely on os.symlink raising NotImplementedError. That would make merging back more difficult, though, so I'd rather keep it like that.
msg236225 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-02-19 17:08
I've read the entire issue and don't believe there's anything to be done here. Plus the originator says in msg204557 "But anyway feel free to close this ticket".
msg236228 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-02-19 17:45
Sounds good to me.
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 63991
2015-02-19 17:45:38steve.dowersetstatus: open -> closed
resolution: wont fix
messages: + msg236228
2015-02-19 17:08:14BreamoreBoysetnosy: + BreamoreBoy, zach.ware, steve.dower
messages: + msg236225
components: + Windows
2013-11-27 15:18:58pitrousetmessages: + msg204597
2013-11-27 15:15:05brian.curtinsetmessages: + msg204595
2013-11-27 07:02:06vajraskysetmessages: + msg204557
2013-11-27 05:18:52brian.curtinsetmessages: + msg204552
2013-11-26 20:33:20pitrousetnosy: + tim.golden, brian.curtin
messages: + msg204530
2013-11-26 07:43:34vajraskycreate