Skip to content

Fix Py_InitializeEx() initsigs parameter - #10516

Closed
hartcw wants to merge 1 commit into
python:masterfrom
hartcw:master
Closed

hartcw wants to merge 1 commit into
python:masterfrom
hartcw:master

Conversation

@hartcw

@hartcw hartcw commented Nov 13, 2018

Copy link
Copy Markdown

I found this bug, and fixed it in my local build.
Please consider for upstreaming.

The Py_InitializeEx() initsigs parameter allows the user to control whether
python registers its own signal handler. However this parameter was being
silently ignored, meaning it was not possible to stop python from registering
its signal handler.

This patch fixes the issue by updating how _PyMainInterpreterConfig struct
is populated, mapping the initsigs parameter to the install_signal_handlers
field on that struct.
@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

Comment thread Modules/main.c
void
_PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *config)
{
config->install_signal_handlers = -1;

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.

I don't think that it's needed, this function is only used to release memory, not to reset a config to the default config.

If you really need to reset to the default config, I would prefer to use _PyMainInterpreterConfig_INIT to reduce maintenance (avoid duplication of code).

Comment thread Modules/main.c
{
_PyMainInterpreterConfig_Clear(config);

config->install_signal_handlers = config2->install_signal_handlers;

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.

I would prefer to use a COPY_ATTR() macro here:

#define COPY_ATTR(ATTR) config->ATTR = config2->ATTR

Rename the existing macro to COPY_OBJ_ATTR(): see _PyCoreConfig_Copy().

@vstinner

Copy link
Copy Markdown
Member

I created https://bugs.python.org/issue35233 to track the bug and I wrote a different fix #10519

My fix includes unit tests and also update test.pythoninfo.

Thanks @hartcw for spotting the bug!

@vstinner vstinner closed this Nov 13, 2018
@vstinner

Copy link
Copy Markdown
Member

Thanks @hartcw, I fixed https://bugs.python.org/issue35233 in the 3.7 and master branches. I found other bugs when I wrote more unit tests :-)

@hartcw

hartcw commented Nov 14, 2018

Copy link
Copy Markdown
Author

OK great, thanks for responding so quickly!

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.

4 participants