FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-33752: Fix a file leak in test_dbm. by serhiy-storchaka · Pull Request #7376 · python/cpython · GitHub

Repository navigation

bpo-33752: Fix a file leak in test_dbm. - #7376

Merged
serhiy-storchaka merged 2 commits into
python:masterfrom
serhiy-storchaka:test_dbm-file-leak
Jun 5, 2018
Merged

serhiy-storchaka merged 2 commits into
python:masterfrom
serhiy-storchaka:test_dbm-file-leak

Conversation

serhiy-storchaka commented Jun 4, 2018 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

With addCleanup() f.close() was executed after tearDown().

https://bugs.python.org/issue33752

With addCleanup() f.close() was executed after tearDown().
Comment thread Lib/test/test_dbm.py Outdated
# create an empty file
test.support.create_empty_file(_fname)

f = dbm.open(_fname, 'n')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Use maybe: try/finally, just in case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There are 11 other calls of close() without try/finally. I had doubts about adding try/finally in all these cases. Maybe in a separate commit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe you can use "with f:" if you don't want to use try/finally :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It is not supported in 2.7. On other side, this PR will be not applied to 2.7, because test_dbm is rudimentary in 2.7.

Comment thread Lib/test/test_dbm.py
@@ -75,10 +75,9 @@ def test_anydbm_creation(self):
def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
# create an empty file
test.support.create_empty_file(_fname)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please keep the empty line. IMHO it helps for the readability.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This test is short (just 4 lines), and no other test method contains an empty line inside. Having an empty line that splits this short test rather adds a false signal that attract an attention to an insignificant detail.

But if you still think that it is worth to restore an empty line, I'll do this.

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

serhiy-storchaka merged commit 6592d7f into python:master Jun 5, 2018

Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

serhiy-storchaka deleted the test_dbm-file-leak branch June 5, 2018 13:03
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 5, 2018
With addCleanup() f.close() was executed after tearDown().
(cherry picked from commit 6592d7f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Copy link
Copy Markdown

GH-7429 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 5, 2018
With addCleanup() f.close() was executed after tearDown().
(cherry picked from commit 6592d7f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Copy link
Copy Markdown

GH-7430 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request Jun 5, 2018
With addCleanup() f.close() was executed after tearDown().
(cherry picked from commit 6592d7f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request Jun 5, 2018
With addCleanup() f.close() was executed after tearDown().
(cherry picked from commit 6592d7f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL