classification
Title: The signal module should raise OSError for OS-related exceptions, not RuntimeError
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, haypo, ncoghlan, pitrou, python-dev
Priority: normal Keywords: patch

Created on 2011-05-05 20:49 by pitrou, last changed 2011-05-10 15:24 by haypo. This issue is now closed.

Files
File name Uploaded Description Edit
signal_oserror.patch haypo, 2011-05-08 23:09 review
Messages (5)
msg135243 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-05 20:49
Treating RuntimeError as if it could take an errno is no good:

>>> try: signal.siginterrupt(32, 12345)
... except RuntimeError as e: print(e.errno)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: (22, 'Invalid argument')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
AttributeError: 'RuntimeError' object has no attribute 'errno'


Changing it breaks compatibility a bit but I think it's worth it.
msg135244 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-05-05 20:56
I asked if I should use RuntimeError or OSError for the new signal functions (#8407) on python-dev. Georg Brandl answered:

"If it has an errno, it should be a subclass of EnvironmentError."
msg135550 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-05-08 23:09
Patch: signal.signal() and signal.siginterrupt() raise an OSError, instead of a RuntimeError: OSError has an errno attribute.
msg135706 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-10 14:19
> Patch: signal.signal() and signal.siginterrupt() raise an OSError,
> instead of a RuntimeError: OSError has an errno attribute.
> 
> ----------
> keywords: +patch
> Added file: http://bugs.python.org/file21939/signal_oserror.patch

Looks good to me.
msg135710 - (view) Author: Roundup Robot (python-dev) Date: 2011-05-10 15:15
New changeset b86b39211ef1 by Victor Stinner in branch 'default':
Issue #12011: signal.signal() and signal.siginterrupt() raise an OSError,
http://hg.python.org/cpython/rev/b86b39211ef1
History
Date User Action Args
2011-05-10 15:24:25hayposetstatus: open -> closed
resolution: fixed
2011-05-10 15:15:04python-devsetnosy: + python-dev
messages: + msg135710
2011-05-10 14:19:25pitrousetmessages: + msg135706
2011-05-08 23:09:43hayposetfiles: + signal_oserror.patch
keywords: + patch
messages: + msg135550
2011-05-05 20:56:33hayposetnosy: + georg.brandl
2011-05-05 20:56:05hayposetmessages: + msg135244
2011-05-05 20:49:39pitroucreate