GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-30860: Fix a refleak. by ericsnowcurrently · Pull Request #3506 · python/cpython

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Sep 11, 2017 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Resolves bpo-31420.

https://bugs.python.org/issue30860

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ericsnowcurrently added 5 commits September 11, 2017 22:14
@ericsnowcurrently
Drop warnoptions from PyInterpreterState.
ec69d0e
@ericsnowcurrently
Drop xoptions from PyInterpreterState.
1c951ca
@ericsnowcurrently
Don't set warnoptions and _xoptions again.
006d9a0
@ericsnowcurrently
Decref after adding to sys.__dict__.
d789ea6
@ericsnowcurrently
Drop an unused macro.
2207aee
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Sep 11, 2017
@bedevere-bot bedevere-bot added the awaiting merge label Sep 11, 2017
@ericsnowcurrently ericsnowcurrently added the skip news label Sep 11, 2017
vstinner
vstinner approved these changes Sep 11, 2017
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented Sep 11, 2017

Copy link
Copy Markdown
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".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ericsnowcurrently
Check sys.xoptions *before* we delete it.
fd6830a
vstinner
vstinner reviewed Sep 12, 2017
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ericsnowcurrently

ericsnowcurrently commented Sep 12, 2017

Copy link
Copy Markdown
Member Author

Yeah, that's what I did.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes Sep 12, 2017
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@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
Revert "bpo-30860: Fix a refleak. (python#3506)"
e532e34
This reverts commit 8728018.
@ericsnowcurrently ericsnowcurrently mentioned this pull request Sep 14, 2017
bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" #3565
Merged
@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
@ericsnowcurrently
bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#…
93c92f7
…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
@Mariatta Mariatta removed the awaiting merge label Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@ericsnowcurrently @vstinner @Mariatta @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.