Re: [Python-Dev] [Python-checkins] r83763 - in python/branches/py3k: Doc/library/signal.rst Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c
This is the idea just popped up. :-) #define SIG(name) if (sig_num != SIG##name) SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) { PyErr_SetString(PyExc_ValueError, "signal number out of range"); return NULL; } #undef SIG
Hirokazu Yamamoto wrote:
#define SIG(name) if (sig_num != SIG##name) SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) { PyErr_SetString(PyExc_ValueError, "signal number out of range");
"Out of range" doesn't seem like quite the right message here, because it suggests a contiguous range of legal values, which isn't the case. -- Greg
On 2010/08/07 19:09, Greg Ewing wrote:
Hirokazu Yamamoto wrote:
#define SIG(name) if (sig_num != SIG##name) SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) { PyErr_SetString(PyExc_ValueError, "signal number out of range");
"Out of range" doesn't seem like quite the right message here, because it suggests a contiguous range of legal values, which isn't the case.
I agree, I suppose "invalid signal number" or something is better.
On 7 Aug, 2010, at 10:24, Hirokazu Yamamoto wrote:
This is the idea just popped up. :-)
#define SIG(name) if (sig_num != SIG##name) SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) { PyErr_SetString(PyExc_ValueError, "signal number out of range"); return NULL; } #undef SIG
What's wrong with: switch (sig_num) { case SIGABRT: case SIGFPE: ... case SIGTERM: break; default: PyErr_SetString(...) return NULL; } That would IMO be clearer than the macro you propose. Ronald
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/ronaldoussoren%40mac.com
On 2010/08/07 19:18, Ronald Oussoren wrote:
On 7 Aug, 2010, at 10:24, Hirokazu Yamamoto wrote:
This is the idea just popped up. :-)
#define SIG(name) if (sig_num != SIG##name) SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) { PyErr_SetString(PyExc_ValueError, "signal number out of range"); return NULL; } #undef SIG
What's wrong with:
switch (sig_num) { case SIGABRT: case SIGFPE: ... case SIGTERM: break; default: PyErr_SetString(...) return NULL; }
That would IMO be clearer than the macro you propose.
Ronald
Hmm... I liked the macro idea, but nothing is wrong with switch statement.
On Sat, Aug 7, 2010 at 08:21, Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>wrote:
On 2010/08/07 19:18, Ronald Oussoren wrote:
On 7 Aug, 2010, at 10:24, Hirokazu Yamamoto wrote:
This is the idea just popped up. :-)
#define SIG(name) if (sig_num != SIG##name) SIG(ABRT) SIG(FPE) SIG(ILL) SIG(INT) SIG(SEGV) SIG(TERM) { PyErr_SetString(PyExc_ValueError, "signal number out of range"); return NULL; } #undef SIG
What's wrong with:
switch (sig_num) { case SIGABRT: case SIGFPE: ... case SIGTERM: break; default: PyErr_SetString(...) return NULL; }
That would IMO be clearer than the macro you propose.
Ronald
Hmm... I liked the macro idea, but nothing is wrong with switch statement.
I had thought about doing this via switch statement. I'll propose a patch and post it on #9324. As for the "out of range" comment -- true, it's not technically a range on Windows, but it matches the exception wording when we raise on Mac/Linux for the same reason. I can change that.
participants (4)
-
Brian Curtin -
Greg Ewing -
Hirokazu Yamamoto -
Ronald Oussoren