Skip to content

Conversation

@ericsnowcurrently
Copy link
Member

@ericsnowcurrentlyericsnowcurrently commented Sep 11, 2017

Copy link
Member

@vstinnervstinner 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

@vstinnervstinner 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
MemberAuthor

Yeah, that's what I did.

Copy link
Member

@vstinnervstinner 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.

@vstinnervstinner merged commit 8728018 into python:masterSep 12, 2017
@ericsnowcurrentlyericsnowcurrently 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
@ericsnowcurrentlyericsnowcurrently restored the fix-31420 branch September 14, 2017 06:26
@ericsnowcurrentlyericsnowcurrently 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.
@ericsnowcurrentlyericsnowcurrently restored the fix-31420 branch September 14, 2017 07:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ericsnowcurrently@vstinner@Mariatta@the-knights-who-say-ni@bedevere-bot