bpo-23325: Turn signal.SIG_DFL and signal.SIG_IGN into functions. by serhiy-storchaka · Pull Request #8920 · python/cpython

@serhiy-storchaka

@serhiy-storchaka

These singletons are no longer integers.
They are now copyable and pickleable and have docstrings.

@pppery

Why should SIG_IGN raise an error when called instead of doing nothing, which is what happens when SIG_IGN is actually supplied as a signal handler?

@serhiy-storchaka

@serhiy-storchaka

Why should SIG_IGN raise an error when called instead of doing nothing, which is what happens when SIG_IGN is actually supplied as a signal handler?

Because currently calling SIG_IGN() raises a TypeError. But I agree, we can make it callable.

@serhiy-storchaka

@pitrou

Hmm, the problem is this will break code such as:

handler = signal.getsignal(signum)
if callable(handler):
   # Do something, e.g. call the handler

iritkatriel

Choose a reason for hiding this comment

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

This has merge conflicts now.

@bedevere-bot

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@encukou

Victor closed the issue, so I'll close the PR too.
They can be reopened together.