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 compare Windows and MinGW paths as equal
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Patrick Lehmann, eryksun, paul.moore, r.david.murray, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-06-17 22:20 by Patrick Lehmann, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg319832 - (view) Author: Patrick Lehmann (Patrick Lehmann) * Date: 2018-06-17 22:20
pathlib does not compare absolute paths from Windows and MinGW as equal.

Windows absolute path: "C:\path\to\tool"
MinGW absolute path: "/c/path/to/tool"
Cygwin absolute path: "/cygdrive/c/path/to/tool"

I consider this a bug, because it's the same bug but 3 different writings and pathlib is not able to identify the equality.


Environment:
Windows 10
Latest MinGW identified in Python 3.6.2 as MINGW64_NT-10.0


Question on Stack Overflow: https://stackoverflow.com/questions/50900779/how-to-compare-absolute-windows-and-mingw-paths-with-pathlib
msg319836 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-06-17 23:47
Sorry, but these paths are not equal in in any sense that Python by itself can determine.  Support for doing this kind of comparison would have to come from MingGW or cygwin, and even if a python library exposed those capabilities, it would be via some new API, because you are effectively asking for a cross-platform comparison of paths.  At least, that's my opinion.  Regardless, this is a feature request and one with enough implications that we can't handle it in the bug tracker.  The way forward with this idea is to discuss the possibility of such an API on the python-ideas mailing list.  Maybe you could even get agreement that normal equality could implement it.  Regardless, you'll need to be able to discuss the MingGW/cygwin facilities that would allow it to be implemented as a minimum starting point.  If those facilities don't exist, there's no hope ;)
msg319846 - (view) Author: Patrick Lehmann (Patrick Lehmann) * Date: 2018-06-18 01:20
I don't think is cross-platform, because I'm still on Windows but in different shells. More over, pathlib currently support cross-platform comparison. I can save a configuration file on Linux and open it on Windows with such paths. I use myPath.as_posix() to solve this problem.

pathlib just needs to detect the environment and then it needs to extend its understanding of equal in MinGW and Cygwin that C:\ is equal to /c/.

That's not a big deal. 

Do I realy need to register in a heavy overloaded mailing list for such a simple fix? This will take months to implement and deploy... 

Python is now on GitHub, why can't we use an issue as any other open source project does?

What is a "MinGW facility"?
msg319854 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2018-06-18 03:52
> I don't think is cross-platform, because I'm still on Windows but 
> in different shells.

MSYS/MINGW64 and Cygwin are POSIX runtime environments implemented in DLLs, but they're layered over Windows and can thus support Windows paths such as r"C:\Temp" in addition to the platform's native paths such as "/c/Temp" or "/cygdrive/c/Temp". 

(The real native path is neither Windows nor POSIX. It's an NT path such as r"\??\C:\Temp", for which r"\??" combines searching the per-logon and global directories that contain device symlinks and "C:" is a symlink to an NT volume device such as r"\Device\HarddiskVolume2". Device symlinks are typically persisted in the registry and stable, such as DOS drives and volume GUID names, whereas actual device names are typically enumerated and unreliable.)

I assume you're using a Python package built for MSYS2. For example:

    $ python
    Python 3.6.2 (default, Sep  7 2017, 13:16:50)
    [GCC 6.3.0] on msys
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import platform
    >>> platform.system()
    'MINGW64_NT-10.0'

(The platform name depends on the value of the MSYSTEM environment variable at startup. In an MSYS development environment it's "MSYS" instead of "MINGW64". In both cases sys.platform is "msys".) 

It seems you want MSYS2 and Cygwin support added to pathlib -- maybe as a subclass of PosixPath. I think David is right that this deserves to be discussed on python-ideas.
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78071
2018-06-18 03:52:53eryksunsetnosy: + eryksun
messages: + msg319854
2018-06-18 01:20:32Patrick Lehmannsetmessages: + msg319846
2018-06-17 23:47:30r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg319836

resolution: not a bug
stage: resolved
2018-06-17 22:20:32Patrick Lehmanncreate