[issue21076] Turn signal.SIG* constants into enums

2020-06-25 Thread STINNER Victor


STINNER Victor  added the comment:

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


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-07-21 Thread Ethan Furman

Changes by Ethan Furman :


--
nosy:  -ethan.furman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-03-29 Thread Ethan Furman

Ethan Furman added the comment:

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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-03-17 Thread Ethan Furman

Ethan Furman added the comment:

Removing the 'enum_to_int' function would also take care of the accepting 
inappropriate types problem.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-03-17 Thread Ethan Furman

Ethan Furman added the comment:

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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-01-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I have other proposition -- turn them into functions (issue23325).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-01-26 Thread Ethan Furman

Ethan Furman added the comment:

I know nothing about this part of CPython, but wouldn't the correct solution be 
to not compare by identity?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-01-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

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.

--
resolution: fixed -> 
stage: resolved -> patch review
type:  -> behavior
Added file: http://bugs.python.org/file37865/signal_no_enum_handlers.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

And more:

>>> import signal
>>> signal.signal(1.2, signal.SIG_DFL)

>>> signal.signal('1', signal.SIG_DFL)


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2015-01-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Now signal.signal() accepts inappropriate types.

>>> signal.signal(signal.SIGHUP, 0.0)

>>> signal.signal(signal.SIGHUP, '0')


In 3.4 it raised an exception.

--
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-04-04 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
assignee:  -> giampaolo.rodola
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-04-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b1f5b5d7997f by Victor Stinner in branch 'default':
Issue #21076: sigpending() is not available on Windows
http://hg.python.org/cpython/rev/b1f5b5d7997f

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-04-04 Thread Roundup Robot

Roundup Robot added the comment:

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

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-04-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

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

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-04-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c9239171e429 by Giampaolo Rodola' in branch 'default':
fix #21076: turn signal module constants into enums
http://hg.python.org/cpython/rev/c9239171e429

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-04-01 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

If there are no other concerns I will commit latest patch tomorrow, then do the 
renaming.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-28 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Updated patch following Victor's suggestions is in attachment.

--
Added file: http://bugs.python.org/file34655/signals4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-28 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

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).

--
Added file: http://bugs.python.org/file34653/signals3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-28 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

(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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

OK, it appears it works now. Sorry for the notification noise.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Added file: http://bugs.python.org/file34643/signals2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Removed file: http://bugs.python.org/file34642/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

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?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Added file: http://bugs.python.org/file34642/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Removed file: http://bugs.python.org/file34640/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Added file: http://bugs.python.org/file34640/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Charles-François Natali

Charles-François Natali added the comment:

This patch can't be reviewed: please re-generate without --git.

--
nosy: +neologix

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Ethan Furman

Changes by Ethan Furman :


--
nosy: +ethan.furman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Guido van Rossum

Changes by Guido van Rossum :


--
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Guido van Rossum

Guido van Rossum added the comment:

OK, somebody please review this (not me).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Removed file: http://bugs.python.org/file34637/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


Added file: http://bugs.python.org/file34637/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21076] Turn signal.SIG* constants into enums

2014-03-27 Thread Giampaolo Rodola'

New submission from Giampaolo Rodola':

Relevant discussion + BDFL approval:
https://mail.python.org/pipermail/python-ideas/2014-March/027286.html
Patch (not tested on Windows) is in attachment.

--
components: Library (Lib)
files: signals.patch
keywords: patch
messages: 214959
nosy: giampaolo.rodola, gvanrossum
priority: normal
severity: normal
status: open
title: Turn signal.SIG* constants into enums
versions: Python 3.5
Added file: http://bugs.python.org/file34636/signals.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com