[issue21382] Signal module doesnt raises ValueError Exception
New submission from rsevcan: 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 ---------- assignee: docs@python components: Documentation messages: 217486 nosy: docs@python, rsevcan priority: normal severity: normal status: open title: Signal module doesnt raises ValueError Exception type: enhancement versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21382> _______________________________________
Changes by Florent Xicluna <florent.xicluna@gmail.com>: ---------- components: +Library (Lib), Windows nosy: +flox type: enhancement -> behavior _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21382> _______________________________________
Florent Xicluna added the comment: 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 ---------- components: -Library (Lib) priority: normal -> low versions: +Python 3.4, Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21382> _______________________________________
Tim Golden added the comment: 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. ---------- nosy: +brian.curtin, tim.golden _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21382> _______________________________________
Roundup Robot added the comment: New changeset 1fcf68e6f4c7 by Berker Peksag in branch '3.5': Issue #21382: Clarify signal.signal() documentation on Windows https://hg.python.org/cpython/rev/1fcf68e6f4c7 New changeset 3e27b21e3a7d by Berker Peksag in branch 'default': Issue #21382: Clarify signal.signal() documentation on Windows https://hg.python.org/cpython/rev/3e27b21e3a7d ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21382> _______________________________________
Changes by Berker Peksag <berker.peksag@gmail.com>: ---------- nosy: +berker.peksag resolution: -> fixed stage: -> resolved status: open -> closed versions: +Python 3.6 -Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21382> _______________________________________
participants (5)
-
Berker Peksag
-
Florent Xicluna
-
Roundup Robot
-
rsevcan
-
Tim Golden