8000 bpo-30860: Fix a refleak. by ericsnowcurrently · Pull Request #3506 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-30860: Fix a refleak. #3506

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

Merged
merged 6 commits into from
Sep 12, 2017
Merged

Conversation

ericsnowcurrently
Copy link
Member
@ericsnowcurrently ericsnowcurrently commented Sep 11, 2017

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

In Py_Main(), read_command_line() is called after _Py_InitializeCore, so after the interpreter had been already created and after the sys module has been initialized.

For example, in Python 3.5, Py_Initialize() was only called after the command line has been parsed.

It seems like past changes now make this change possible and correct.

@vstinner
Copy link
Member

Oh, test_showrefcount() of test_cmd_line fails. You have to check sys._xoptions['showrefcount'] before calling _PyDebug_PrintTotalRefs(). Move the following _PyDebug_PrintTotalRefs() code:

    xoptions = PySys_GetXOptions();
    if (xoptions == NULL)
        return;
    value = _PyDict_GetItemId(xoptions, &PyId_showrefcount);
    if (value == Py_True)

in Py_FinalizeEx(), before _PyImport_Fini().

Since _PyDebug_PrintTotalRefs() is private, it's ok to rewrite it to move the test into the caller. But you have to take care of "#ifdef Py_REF_DEBUG".

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

If you use #ifdef Py_REF_DEBUG, maybe _PY_DEBUG_PRINT_TOTAL_REFS() macro can go away.

@ericsnowcurrently
Copy link
Member Author

Yeah, that's what I did.

Copy link
Member
@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

Ah yes, you removed the macro. Nice.

LGTM.

@vstinner vstinner merged commit 8728018 into python:master Sep 12, 2017
@ericsnowcurrently ericsnowcurrently deleted the fix-31420 branch September 12, 2017 01:00
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this pull request Sep 14, 2017
@ericsnowcurrently ericsnowcurrently restored the fix-31420 branch September 14, 2017 06:26
@ericsnowcurrently ericsnowcurrently deleted the fix-31420 branch September 14, 2017 06:30
ericsnowcurrently added a commit that referenced this pull request Sep 14, 2017
…3565)

PR #1638, for bpo-28411, causes problems in some (very) edge cases. Until that gets sorted out, we're reverting the merge. PR #3506, a fix on top of #1638, is also getting reverted.
@ericsnowcurrently ericsnowcurrently restored the fix-31420 branch September 14, 2017 07:13
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.

5 participants
0