Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal module doesnt raises ValueError Exception #65581

Closed
rsevcan mannequin opened this issue Apr 29, 2014 · 4 comments
Closed

Signal module doesnt raises ValueError Exception #65581

rsevcan mannequin opened this issue Apr 29, 2014 · 4 comments
Labels
docs Documentation in the Doc dir OS-windows type-bug An unexpected behavior, bug, or error

Comments

@rsevcan
Copy link
Mannequin

rsevcan mannequin commented Apr 29, 2014

BPO 21382
Nosy @tjguk, @briancurtin, @florentx, @berkerpeksag

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-04-23.23:59:58.665>
created_at = <Date 2014-04-29.08:17:16.354>
labels = ['type-bug', 'OS-windows', 'docs']
title = 'Signal module doesnt raises ValueError Exception'
updated_at = <Date 2016-04-23.23:59:58.663>
user = 'https://bugs.python.org/rsevcan'

bugs.python.org fields:

activity = <Date 2016-04-23.23:59:58.663>
actor = 'berker.peksag'
assignee = 'docs@python'
closed = True
closed_date = <Date 2016-04-23.23:59:58.665>
closer = 'berker.peksag'
components = ['Documentation', 'Windows']
creation = <Date 2014-04-29.08:17:16.354>
creator = 'rsevcan'
dependencies = []
files = []
hgrepos = []
issue_num = 21382
keywords = []
message_count = 4.0
messages = ['217486', '217531', '217996', '264077']
nosy_count = 7.0
nosy_names = ['tim.golden', 'brian.curtin', 'flox', 'docs@python', 'python-dev', 'berker.peksag', 'rsevcan']
pr_nums = []
priority = 'low'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue21382'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

@rsevcan
Copy link
Mannequin Author

rsevcan mannequin commented Apr 29, 2014

signal.signal() built-in function doesnt throws a ValueError exception in Windows when is called with a different signal than SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM, as it is written in the documentation.

https://docs.python.org/2/library/signal.html#signal.signal
https://docs.python.org/3/library/signal.html#signal.signal

It throws an AttributeError Exception

>>> import signal
>>> import sys
>>> sys.platform
'win32'
>>> signal.signal(signal.SIGPIPE, lambda signum, frame: sys.exit(1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SIGPIPE'
>>>

Regards

@rsevcan rsevcan mannequin added the type-feature A feature request or enhancement label Apr 29, 2014
@rsevcan rsevcan mannequin assigned docspython Apr 29, 2014
@rsevcan rsevcan mannequin added the docs Documentation in the Doc dir label Apr 29, 2014
@florentx florentx mannequin added stdlib Python modules in the Lib dir OS-windows type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Apr 29, 2014
@florentx
Copy link
Mannequin

florentx mannequin commented Apr 29, 2014

It's about documentation only.

The sentence is not wrong, but it is slightly confusing, and there's no hint which signals are defined on Windows.

"On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case."

Reading only this documentation, if the developer doesn't have a test platform on Windows, he could blindly write:

try:
signal.signal(signal.SIGPIPE, lambda signum, frame: sys.exit(1))
except ValueError:
pass

... until a Windows user detects the issue (thank you rsevcan)

Now I just found this page which is relevant here ... either we could link to the page in a "See also" section, or give an hint about which signals are defined or not.
http://msdn.microsoft.com/en-us/library/xdkz3x12.aspx

@florentx florentx mannequin removed the stdlib Python modules in the Lib dir label Apr 29, 2014
@tjguk
Copy link
Member

tjguk commented May 6, 2014

To be honest I can't get excited about this one. The only sensible change is to remove the rather specific comment about ValueError and just leave the fact that only certain signals are valid.

Because the C code defines module-level constants on the basis of whether the platform C-lib defines them, different platforms will have different module attributes. It would be unusual for us to list all the combinations.

Adding Brian Curtin as he made the original change.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Apr 23, 2016

New changeset 1fcf68e6f4c7 by Berker Peksag in branch '3.5':
Issue bpo-21382: Clarify signal.signal() documentation on Windows
https://hg.python.org/cpython/rev/1fcf68e6f4c7

New changeset 3e27b21e3a7d by Berker Peksag in branch 'default':
Issue bpo-21382: Clarify signal.signal() documentation on Windows
https://hg.python.org/cpython/rev/3e27b21e3a7d

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants