classification
Title: Turn signal.SIG* constants into enums
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: giampaolo.rodola Nosy List: ethan.furman, giampaolo.rodola, gvanrossum, haypo, neologix, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-03-27 15:48 by giampaolo.rodola, last changed 2014-04-04 18:27 by giampaolo.rodola. This issue is now closed.

Files
File name Uploaded Description Edit
signals.patch giampaolo.rodola, 2014-03-27 15:48
signals2.patch giampaolo.rodola, 2014-03-27 23:28 review
signals3.patch giampaolo.rodola, 2014-03-28 17:13 review
signals4.patch giampaolo.rodola, 2014-03-28 19:40 review
Messages (13)
msg214959 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-03-27 15:48
Relevant discussion + BDFL approval:
https://mail.python.org/pipermail/python-ideas/2014-March/027286.html
Patch (not tested on Windows) is in attachment.
msg214960 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-03-27 16:09
OK, somebody please review this (not me).
msg214985 - (view) Author: Charles-Fran├žois Natali (neologix) * (Python committer) Date: 2014-03-27 22:10
This patch can't be reviewed: please re-generate without --git.
msg214993 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-03-27 23:02
This time I made it without --git but that didn't help either.
Not sure what to do. :-\

Note: the devguide recommends using --git BTW: http://docs.python.org/devguide/committing.html
Should that be changed?
msg215003 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-03-27 23:35
OK, it appears it works now. Sorry for the notification noise.
msg215042 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-03-28 12:52
(replying here 'cause rietveld keeps giving me an exception when I submit a reply)

On 2014/03/28 00:49:47, haypo wrote:
> http://bugs.python.org/review/21076/diff/11457/Lib/signal.py
> File Lib/signal.py (right):
> 
> http://bugs.python.org/review/21076/diff/11457/Lib/signal.py#newcode7
> Lib/signal.py:7: if name.isupper()
> You can probably remove this test.
> 
> http://bugs.python.org/review/21076/diff/11457/Lib/signal.py#newcode8
> Lib/signal.py:8: and (name.startswith('SIG') and not name.startswith('SIG_'))
> Why do you ignore SIG_DFL, SIG_IGN, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK? It may
> also be interesting to provide enums for them. They are just integers (0, 1 or
> 2) on my Linux.

I guess it makes sense.
I'm now realizing that the patch as-is is incomplete as the other "get" APIs (signal.getsignal() and others) still return integers: they should be overridden in order to convert integers into enums, similarly to http://hg.python.org/cpython/file/d8659dbebfd1/Lib/socket.py#l262
I will do that.
msg215059 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-03-28 17:13
New patch in attachment provides 3 enum containers and overrides all the necessary signal module APIs so that they interoperate with enums on both "get" and "set".
I decided *not* to rename signamodule.c to _signamodule.c in this patch so that it is easier to review (I will do the renaming as a second step).
msg215072 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-03-28 19:40
Updated patch following Victor's suggestions is in attachment.
msg215332 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-04-01 16:54
If there are no other concerns I will commit latest patch tomorrow, then do the renaming.
msg215519 - (view) Author: Roundup Robot (python-dev) Date: 2014-04-04 13:34
New changeset c9239171e429 by Giampaolo Rodola' in branch 'default':
fix #21076: turn signal module constants into enums
http://hg.python.org/cpython/rev/c9239171e429
msg215521 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-04-04 13:50
http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%203.x/builds/4131/steps/compile/logs/stdio

gcc -pthread   -Xlinker -export-dynamic -o Modules/_testembed Modules/_testembed.o libpython3.5dm.a -lpthread -ldl  -lutil   -lm  
libpython3.5dm.a(config.o):(.data+0x18): undefined reference to `PyInit_signal'
collect2: ld returned 1 exit status
make: *** [Modules/_testembed] Error 1
msg215526 - (view) Author: Roundup Robot (python-dev) Date: 2014-04-04 14:31
New changeset df5120efb86e by Victor Stinner in branch 'default':
Issue #21076: the C signal module has been renamed to _signal
http://hg.python.org/cpython/rev/df5120efb86e
msg215528 - (view) Author: Roundup Robot (python-dev) Date: 2014-04-04 15:00
New changeset b1f5b5d7997f by Victor Stinner in branch 'default':
Issue #21076: sigpending() is not available on Windows
http://hg.python.org/cpython/rev/b1f5b5d7997f
History
Date User Action Args
2014-04-04 18:27:23giampaolo.rodolasetstatus: open -> closed
assignee: giampaolo.rodola
resolution: fixed
stage: patch review -> resolved
2014-04-04 15:00:14python-devsetmessages: + msg215528
2014-04-04 14:31:46python-devsetmessages: + msg215526
2014-04-04 13:50:26serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg215521
2014-04-04 13:34:28python-devsetnosy: + python-dev
messages: + msg215519
2014-04-01 16:54:09giampaolo.rodolasetmessages: + msg215332
2014-03-28 19:40:10giampaolo.rodolasetfiles: + signals4.patch

messages: + msg215072
2014-03-28 17:13:39giampaolo.rodolasetfiles: + signals3.patch

messages: + msg215059
2014-03-28 12:52:09giampaolo.rodolasetmessages: + msg215042
2014-03-27 23:35:25giampaolo.rodolasetmessages: + msg215003
2014-03-27 23:28:41giampaolo.rodolasetfiles: + signals2.patch
2014-03-27 23:09:07giampaolo.rodolasetfiles: - signals.patch
2014-03-27 23:02:10giampaolo.rodolasetmessages: + msg214993
2014-03-27 22:58:35giampaolo.rodolasetfiles: + signals.patch
2014-03-27 22:56:54giampaolo.rodolasetfiles: - signals.patch
2014-03-27 22:56:32giampaolo.rodolasetfiles: + signals.patch
2014-03-27 22:38:24hayposetnosy: + haypo
2014-03-27 22:10:13neologixsetnosy: + neologix
messages: + msg214985
2014-03-27 16:10:09ethan.furmansetnosy: + ethan.furman
2014-03-27 16:09:39gvanrossumsetstage: patch review
2014-03-27 16:09:27gvanrossumsetmessages: + msg214960
2014-03-27 15:55:28giampaolo.rodolasetfiles: - signals.patch
2014-03-27 15:55:19giampaolo.rodolasetfiles: + signals.patch
2014-03-27 15:48:50giampaolo.rodolacreate