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

bpo-29573: Fixed unlinking already removed NamedTemporaryFile. #134

Closed
wants to merge 1 commit into from
Closed

bpo-29573: Fixed unlinking already removed NamedTemporaryFile. #134

wants to merge 1 commit into from

Conversation

andrewnester
Copy link
Contributor

@andrewnester andrewnester commented Feb 16, 2017

Copy link
Member

@briancurtin briancurtin left a comment

Choose a reason for hiding this comment

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

Looks fine to me, just needs a small test change.

@@ -957,6 +957,12 @@ def test_bad_mode(self):
tempfile.NamedTemporaryFile(mode=2, dir=dir)
self.assertEqual(os.listdir(dir), [])

def test_if_temp_file_already_removed(self):
tmpdir = tempfile.mkdtemp()
Copy link
Member

Choose a reason for hiding this comment

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

Should add a self.addCleanup on that tmpdir—see the test above (test_bad_mode) for an example, just to make sure that if this test ever does fail that we don't have a temp dir that doesn't get cleaned up by us.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@briancurtin right, thanks! fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@briancurtin could you please review it again, it's fixed now

tmpdir = tempfile.mkdtemp()
self.addCleanup(support.rmtree, tmpdir)
with tempfile.NamedTemporaryFile(delete=True, dir=tmpdir) as fp:
os.system('rm {}'.format(fp.name))
Copy link
Member

Choose a reason for hiding this comment

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

Why does this use os.system to call rm, rather than calling os.unlink? 'rm' is not exactly cross-platform. This test will also fail on Windows (and other systems where you can't delete files that are currently in use). It'll have to be skipped on those platforms.

akruis pushed a commit to akruis/cpython that referenced this pull request Oct 29, 2017
Replace the direct access to PyObject members with the preferred macros.
@brettcannon
Copy link
Member

To try and help move older pull requests forward, we are going through and backfilling 'awaiting' labels on pull requests that are lacking the label. Based on the current reviews, the best we can tell in an automated fashion is that a core developer requested changes to be made to this pull request.

If/when the requested changes have been made, please leave a comment that says, I have made the requested changes; please review again. That will trigger a bot to flag this pull request as ready for a follow-up review.

@serhiy-storchaka serhiy-storchaka changed the title bpo-29573 - Fixed unlinking already removed NamedTemporaryFile. bpo-29573: Fixed unlinking already removed NamedTemporaryFile. Mar 26, 2018
akruis pushed a commit to akruis/cpython that referenced this pull request Jun 19, 2018
Replace the direct access to PyObject members with the preferred macros.
(cherry picked from commit c7dcca5)
@csabella csabella requested a review from briancurtin May 20, 2019 00:56
@flavianh
Copy link

flavianh commented Jul 21, 2019

@briancurtin @Yhg1s @brettcannon Is this PR worth being revived? The user's repo does not exist any more. I could take care of it by creating a new PR if you want

@brettcannon
Copy link
Member

@flavianh up to you if you want to create a new PR to try and solve the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants