← 返回首页
bpo-1635741: Port _gdbm module to multiphase initialization by corona10 · Pull Request #20920 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-1635741: Port _gdbm module to multiphase initialization#20920

Merged
corona10 merged 3 commits into
python:masterfrom
corona10:bpo-1635741-gdbm
Jun 16, 2020
Merged

bpo-1635741: Port _gdbm module to multiphase initialization#20920
corona10 merged 3 commits into
python:masterfrom
corona10:bpo-1635741-gdbm

Conversation

corona10 commented Jun 16, 2020
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

corona10 commented Jun 16, 2020
edited
Loading

Copy link
Copy Markdown
Member Author

I' ve checked the memory leak with these scripts and no leaks found

./python.exe -m test test_dbm_gnu -R 3:3
def test_gdbm(self): code = textwrap.dedent(r""" import glob import test.support dbm = test.support.import_module('_gdbm') # or dbm = test.support.import_module('dbm') _fname = test.support.TESTFN def delete_files(): for f in glob.glob(_fname + "*"): test.support.unlink(f) f = dbm.open(_fname, 'n') f[b'g'] = b"indented" f.close() delete_files() """) ret = test.support.run_in_subinterp(code) self.assertEqual(ret, 0)

Copy link
Copy Markdown
Member Author

Note that dbm = test.support.import_module('dbm') is leaked at the master branch :)

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 Hide comment

LGTM.

Minor remarks:

  • I'm not sure why only a few methods uses the defining class, whereas some others use Py_TYPE(self).
  • nitpick: some "clinic input" uses an empty line betwen the function name and its parameters, sometimes there is none.

But I don't think that it's worth it to address these minor things. If you care, you may also update _dbmmodule.c. Maybe in a follow-up PRs.

Comment thread Modules/_gdbmmodule.c Show resolved Hide resolved

Copy link
Copy Markdown
Member

Note that dbm = test.support.import_module('dbm') is leaked at the master branch :)

Maybe open an issue to track this bug.

Copy link
Copy Markdown
Member

Maybe open an issue to track this bug.

Well, I added a comment to: https://bugs.python.org/issue40987#msg371679

Copy link
Copy Markdown
Member Author

@vstinner

Maybe open an issue to track this bug

Oh I mean the subinterpreter test with dbm = test.support.import_module('dbm')is leaked
With this change, there is no leak.

corona10 merged commit c4862e3 into python:master Jun 16, 2020

Copy link
Copy Markdown
Member Author

@vstinner Thanks for the review!

Copy link
Copy Markdown
Member

With this change, there is no leak.

Oh ok, that's great! Sorry, I misunderstood your comment.

corona10 deleted the bpo-1635741-gdbm branch February 15, 2024 01:41
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Footer

© 2026 GitHub, Inc.