msg214959 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) * |
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) * |
Date: 2014-03-27 16:09 |
OK, somebody please review this (not me).
|
msg214985 - (view) |
Author: Charles-François Natali (neologix) * |
Date: 2014-03-27 22:10 |
This patch can't be reviewed: please re-generate without --git.
|
msg214993 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) * |
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) * |
Date: 2014-03-27 23:35 |
OK, it appears it works now. Sorry for the notification noise.
|
msg215042 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) * |
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) * |
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) * |
Date: 2014-03-28 19:40 |
Updated patch following Victor's suggestions is in attachment.
|
msg215332 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) * |
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) * |
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
|
msg234608 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2015-01-24 12:59 |
Now signal.signal() accepts inappropriate types.
>>> signal.signal(signal.SIGHUP, 0.0)
<Handlers.SIG_DFL: 0>
>>> signal.signal(signal.SIGHUP, '0')
<Handlers.SIG_DFL: 0>
In 3.4 it raised an exception.
|
msg234610 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2015-01-24 13:02 |
And more:
>>> import signal
>>> signal.signal(1.2, signal.SIG_DFL)
<Handlers.SIG_DFL: 0>
>>> signal.signal('1', signal.SIG_DFL)
<Handlers.SIG_DFL: 0>
|
msg234768 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2015-01-26 18:59 |
And more, as far as standard signal handler is tested for identity, signal.SIG_DFL and _signal.SIG_DFL should be the same object. Current code works only due to coincidence of two circumstances:
1) Small integers are cached in CPython.
2) SIG_DFL and SIG_IGN are small integers on common platforms.
When small integer caching is disabled (NSMALLPOSINTS == NSMALLPOSINTS == 0) or when platform depended macros SIG_DFL and SIG_IGN are not small integers, the signal module will mystically fail.
The simplest way to solve this issue is to backout turning SIG_DFL and SIG_IGN into enums.
|
msg234770 - (view) |
Author: Ethan Furman (ethan.furman) * |
Date: 2015-01-26 19:06 |
I know nothing about this part of CPython, but wouldn't the correct solution be to not compare by identity?
|
msg234776 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) * |
Date: 2015-01-26 20:39 |
I have other proposition -- turn them into functions (issue23325).
|
msg238317 - (view) |
Author: Ethan Furman (ethan.furman) * |
Date: 2015-03-17 17:06 |
Working on issue23673 I saw this in the new signal.py:
+def _enum_to_int(value):
+ """Convert an IntEnum member to a numeric value.
+ If it's not a IntEnum member return the value itself.
+ """
+ try:
+ return int(value)
+ except (ValueError, TypeError):
+ return value
The SIG, etc, constants are based on IntEnum, so they are already numeric values, and this function is unnecessary.
|
msg238319 - (view) |
Author: Ethan Furman (ethan.furman) * |
Date: 2015-03-17 17:09 |
Removing the 'enum_to_int' function would also take care of the accepting inappropriate types problem.
|
msg239556 - (view) |
Author: Ethan Furman (ethan.furman) * |
Date: 2015-03-30 01:55 |
Okay, in a perfect world that _enum_to_int function would be unnecessary, but as Serhiy pointed out the C code is doing pointer comparison, so unless the exact same int is passed in it does not work.
I'm looking at adjusting the C code.
|
msg372322 - (view) |
Author: STINNER Victor (vstinner) * |
Date: 2020-06-25 09:30 |
signal constants are now enum, I close the issue. For further enhancements, please open a separated issue.
$ python3
Python 3.8.3 (default, May 15 2020, 00:00:00)
>>> import signal; signal.SIGTERM
<Signals.SIGTERM: 15>
|
|
Date |
User |
Action |
Args |
2022-04-11 14:58:00 | admin | set | github: 65275 |
2020-06-25 09:30:58 | vstinner | set | status: open -> closed resolution: fixed messages:
+ msg372322
stage: patch review -> resolved |
2015-07-21 07:22:03 | ethan.furman | set | nosy:
- ethan.furman
|
2015-03-30 01:55:12 | ethan.furman | set | messages:
+ msg239556 |
2015-03-17 17:09:23 | ethan.furman | set | messages:
+ msg238319 |
2015-03-17 17:06:24 | ethan.furman | set | messages:
+ msg238317 |
2015-01-26 20:39:42 | serhiy.storchaka | set | messages:
+ msg234776 |
2015-01-26 19:06:55 | ethan.furman | set | messages:
+ msg234770 |
2015-01-26 18:59:07 | serhiy.storchaka | set | files:
+ signal_no_enum_handlers.patch type: behavior messages:
+ msg234768
resolution: fixed -> (no value) stage: resolved -> patch review |
2015-01-24 13:02:21 | serhiy.storchaka | set | messages:
+ msg234610 |
2015-01-24 12:59:12 | serhiy.storchaka | set | status: closed -> open
messages:
+ msg234608 |
2014-04-04 18:27:23 | giampaolo.rodola | set | status: open -> closed assignee: giampaolo.rodola resolution: fixed stage: patch review -> resolved |
2014-04-04 15:00:14 | python-dev | set | messages:
+ msg215528 |
2014-04-04 14:31:46 | python-dev | set | messages:
+ msg215526 |
2014-04-04 13:50:26 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages:
+ msg215521
|
2014-04-04 13:34:28 | python-dev | set | nosy:
+ python-dev messages:
+ msg215519
|
2014-04-01 16:54:09 | giampaolo.rodola | set | messages:
+ msg215332 |
2014-03-28 19:40:10 | giampaolo.rodola | set | files:
+ signals4.patch
messages:
+ msg215072 |
2014-03-28 17:13:39 | giampaolo.rodola | set | files:
+ signals3.patch
messages:
+ msg215059 |
2014-03-28 12:52:09 | giampaolo.rodola | set | messages:
+ msg215042 |
2014-03-27 23:35:25 | giampaolo.rodola | set | messages:
+ msg215003 |
2014-03-27 23:28:41 | giampaolo.rodola | set | files:
+ signals2.patch |
2014-03-27 23:09:07 | giampaolo.rodola | set | files:
- signals.patch |
2014-03-27 23:02:10 | giampaolo.rodola | set | messages:
+ msg214993 |
2014-03-27 22:58:35 | giampaolo.rodola | set | files:
+ signals.patch |
2014-03-27 22:56:54 | giampaolo.rodola | set | files:
- signals.patch |
2014-03-27 22:56:32 | giampaolo.rodola | set | files:
+ signals.patch |
2014-03-27 22:38:24 | vstinner | set | nosy:
+ vstinner
|
2014-03-27 22:10:13 | neologix | set | nosy:
+ neologix messages:
+ msg214985
|
2014-03-27 16:10:09 | ethan.furman | set | nosy:
+ ethan.furman
|
2014-03-27 16:09:39 | gvanrossum | set | stage: patch review |
2014-03-27 16:09:27 | gvanrossum | set | messages:
+ msg214960 |
2014-03-27 15:55:28 | giampaolo.rodola | set | files:
- signals.patch |
2014-03-27 15:55:19 | giampaolo.rodola | set | files:
+ signals.patch |
2014-03-27 15:48:50 | giampaolo.rodola | create | |