-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add unit tests for easy-install.pth uninstall #6517
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, but it doesn't need addressing and I'm +1 on this change.
@@ -593,7 +593,7 @@ def add(self, entry): | |||
# backslashes. This is correct for entries that describe absolute | |||
# paths outside of site-packages, but all the others use forward | |||
# slashes. | |||
if WINDOWS and not os.path.splitdrive(entry)[0]: | |||
if WINDOWS and not os.path.isabs(entry): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this will behave differently on a non-absolute path with a drive letter, like C:foo\bar
. To be honest, though, I can't imagine why we'd ever encounter a real life case where that would happen, so I'm inclined to ignore the issue. And as a general point, isabs
seems clearer to me.
My only (very slight) reservation is that not using isabs
in the first place is non-obvious enough that thee may have been a reason for it. But it seems to have been introduced in 770930d, without comment, so I'm inclined to think there was no particular motive.
Looks like there are some test failures that will need addressing, though :-) |
b4574f2
to
f871d41
Compare
https://stackoverflow.com/a/42014874 The problem with the test was due to a change in python 2.7.8 where Testing on 2.7.15, I get the following results: >>> p = '\\\\example\\share\\case'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
False False ('\\\\example\\share', '\\case')
>>> p = '\\\\example\\share\\'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
False False ('\\\\example\\share', '\\')
>>> p = '\\\\example\\share'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
True False ('\\\\example\\share', '')
>>> p = '\\\\example'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
False True ('', '\\\\example')
>>> p = 'C:\\foo\\bar'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
False False ('C:', '\\foo\\bar')
>>> p = 'C:foo\\bar'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
True False ('C:', 'foo\\bar')
>>> p = 'foo\\bar'; print not os.path.isabs(p), not os.path.splitdrive(p)[0], os.path.splitdrive(p)
True True ('', 'foo\\bar') It looks like The root of the problem was due to me using a old un-supported version of python. If you want I can revert the change to isabs, but leave the unit test changes, or just close the pull request. |
If nothing else, I think it would be worth documenting your findings in a code comment so it won’t need to be rediscovered and because it seems obscure. |
Excellent bit of diagnosis! I agree with @cjerdonek that documenting the reason that |
f871d41
to
d62bef4
Compare
Documentation added to req_uninstall.py and original splitdrive check restored. |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Anything else needed for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some code style disagreements but I'm okay functionally.
I'll defer to others to merge though.
Thanks for the contribution! |
Resolves issue #6516.
If uninstalling a editable package in Python 2.7 that was installed using a UNC file path, the path is not removed from the easy-install.pth file.
Change use of
os.path.splitdrive
toos.path.isabs
and add unit tests for .pth file handling.