-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
resolve(strict=True) is not case-sensitive on Windows and Python 2.7 #84
Comments
Thanks for reporting this and I'm sorry nobody has responded to this yet. Though perhaps there might be something that could be done, the library is no longer maintained on Python 2.7... Anyway, the code responsible for this is likely at https://github.com/jazzband/pathlib2/blob/develop/src/pathlib2/_ntpath.py which was backported (i.e. copied) from CPython 3.x at some point. An upstream resync might fix it (or not... in which case we'd have to dig deeper). @hendrikmakait What do you think? |
Apologies, I made a mistake in my analysis. The old Python 2.7 version uses the develop-py2 branch whilst I was looking at the develop branch which is Python 3.x only. The correct reference is: https://github.com/jazzband/pathlib2/blob/develop-py2/pathlib2/__init__.py#L1487 |
I added a quick regression test for this. Unfortunately the test passes on my system, so I'm at loss as to how to reproduce this... For the record, the test lives here (it's on top of the develop-py2 branch): |
Here's a slightly corrected version that actually tests the case problem: develop-py2...feature/test-issue-84 Note that Whilst ideally canonicalizing paths (such as with resolve) would also ensure their case is as on the filesystem on Windows, the implementation on Python 2.7 simply doesn't do that because it is missing some built-in functions that are only available on Python 3.x. In my opinion, adding those in is likely a non-trivial undertaking, and will be more than a one-line patch that could be put in a quick post release. Couple that with Python 2.7 being EOL for a really long time now, it seems not worth the effort and risk of trying to properly fix this now, in my opinion. If possible, if you really still need to rely on Python 2.7, I recommend that you write your code so you don't rely on case sensitivity on Windows, as the API doesn't make such promise (though it behaves that way on Python 3.x). |
Good day ladies and gentlemen,
I have a problem with the
pathlib2.Path().resolve(strict=True)
andpython-2
.This function is case-sensitive when running with
python-3
but not when run withpython-2
.In the example in the screenshot I would expect
pathlib2.Path("C:/temp/garbage.txt").resolve(strict=True)
to returnC:/temp/gArbage.txt
instead ofC:/temp/garbage.txt
.See screenshot (old screenshot where I tested
python-3
againspathlib
):I tested on Windows 10 with
python-2.7.17
,pathlib2-2.3.3
andpathlib2-2.3.7.post1
.I doublechecked
python-3.7.5
withpathlib2-2.3.7.post1
. This will resolve correctly. So it is apython-2
specific problem.Thanks in advance for looking into it!
The text was updated successfully, but these errors were encountered: