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

Delete tmpdir with rmtree to handle Unicode paths #7572

Merged
merged 1 commit into from
Jan 8, 2020

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Jan 8, 2020

pytest (rather py.path.local) does not handle non-ASCII paths properly on Windows with Python 2, but Python's builtin shutil.rmtree() does.

This becomes a problem when writing a test case for #7138. The test data for it (a non-ASCII data file) would choke pytest and fail on clean-up for any tests using the test data.

pytest (rather py.path.local) does not handle non-ASCII paths properly
on Windows with Python 2, but Python's builtin shutil.rmtree() does.

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
@pradyunsg pradyunsg added C: tests Testing and related things skip news Does not need a NEWS file entry (eg: trivial changes) type: bugfix labels Jan 8, 2020
@pradyunsg
Copy link
Member

This PR restores my faith that Python 2 is evil and should be eliminated from the face of the planet... or at least our support matrix. ;P

@pradyunsg pradyunsg requested a review from pfmoore January 8, 2020 13:07
@pradyunsg
Copy link
Member

Requested review from @pfmoore because I'm sure he'll enjoy this. We spent all day on this. :)

@pfmoore
Copy link
Member

pfmoore commented Jan 8, 2020

We spent all day on this. :)

Gotta love those Unicode bugs :-)

@pradyunsg
Copy link
Member

That was a quick review. 😆

@pfmoore
Copy link
Member

pfmoore commented Jan 8, 2020

Happened to see the email. To be fair, I haven't run the code, I don't have Python 2 installed on this PC, but that's what CI is for, isn't it? ;-) But desk checking it, it looks fine to me.

@pradyunsg
Copy link
Member

pradyunsg commented Jan 8, 2020

Gotta love those Unicode bugs :-)

The test for pip failed because it couldn't delete the unicode directory, then scripttest's error message generation failed, because it tried to print an error message containing the name of the directory that couldn't be deleted, because the original test had failed to delete the unicode directory.

Cause: a str was passed to the delete call instead of unicode + pytest's handler couldn't delete a unicode directory.
Result: everything is broken and there's no useful error message on the test's failure.

@pfmoore
Copy link
Member

pfmoore commented Jan 8, 2020

Impressive bit of detective work!

@pradyunsg pradyunsg merged commit 0eaf0e6 into pypa:master Jan 8, 2020
@@ -103,7 +103,7 @@ def tmpdir(request, tmpdir):
# This should prevent us from needing a multiple gigabyte temporary
# directory while running the tests.
if not request.config.getoption("--keep-tmpdir"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment might have been a good idea here, to explain the use of shutil.rmtree (to prevent a possible accidental revert in a distant future)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the comments in a follow-up PR #7577

@uranusjr uranusjr deleted the tmpdir-cleanup-py2-win branch January 13, 2020 09:27
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Feb 12, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: tests Testing and related things skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants