diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-11 01:06:40 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-11 01:06:40 (GMT) |
commit | b76922a7be9196af9281cd2d167f1afd81d1fb6e (patch) | |
tree | 5691f4e12412bad9256e621fee671b2c6465c321 /Modules | |
parent | ad8dcd5f1af1b2a6b64040163d011628ab4f7691 (diff) | |
download | cpython-b76922a7be9196af9281cd2d167f1afd81d1fb6e.zip cpython-b76922a7be9196af9281cd2d167f1afd81d1fb6e.tar.gz cpython-b76922a7be9196af9281cd2d167f1afd81d1fb6e.tar.bz2 |
Merged revisions 59450-59464 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59455 | guido.van.rossum | 2007-12-10 21:42:53 +0100 (Mon, 10 Dec 2007) | 2 lines
Remove a 2.2-ism.
........
r59459 | christian.heimes | 2007-12-10 23:28:56 +0100 (Mon, 10 Dec 2007) | 4 lines
Backport of r59456:59458 from py3k to trunk
Issue #1580: New free format floating point representation based on "Floating-Point Printer Sample Code", by Robert G. Burger. For example repr(11./5) now returns '2.2' instead of '2.2000000000000002'.
Thanks to noam for the patch! I had to modify doubledigits.c slightly to support X64 and IA64 machines on Windows. I also added the new file to the three project files.
........
r59460 | guido.van.rossum | 2007-12-11 00:00:12 +0100 (Tue, 11 Dec 2007) | 4 lines
Patch #1643738 by Ulisses Furquim -- make the is_tripped variable
in signalmodule.c more robust. Includes Martin von Loewis's suggestion
to set is_tripped after .tripped.
........
r59463 | kurt.kaiser | 2007-12-11 01:04:57 +0100 (Tue, 11 Dec 2007) | 2 lines
format_paragraph_event wasn't returning 'break'
........
r59464 | christian.heimes | 2007-12-11 01:54:34 +0100 (Tue, 11 Dec 2007) | 3 lines
The new float repr causes too much trouble and pain. I'm disabling the feature until we have sorted out the issues on all machines. 64bit machines seem to have issues and Guido has reported even worse.
Guido: It's pretty bad actually -- repr(1e5) comes out as '1.0'... Ditto for
repr(1eN) for most N... Both in 2.6 and in 3.0...
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/signalmodule.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 5f38b9b..76c8198 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -75,7 +75,8 @@ static struct { PyObject *func; } Handlers[NSIG]; -static int is_tripped = 0; /* Speed up sigcheck() when none tripped */ +/* Speed up sigcheck() when none tripped */ +static volatile sig_atomic_t is_tripped = 0; static PyObject *DefaultHandler; static PyObject *IgnoreHandler; @@ -122,8 +123,10 @@ signal_handler(int sig_num) /* See NOTES section above */ if (getpid() == main_pid) { #endif - is_tripped++; Handlers[sig_num].tripped = 1; + /* Set is_tripped after setting .tripped, as it gets + cleared in PyErr_CheckSignals() before .tripped. */ + is_tripped = 1; Py_AddPendingCall(checksignals_witharg, NULL); #ifdef WITH_THREAD } @@ -597,13 +600,31 @@ PyErr_CheckSignals(void) if (!is_tripped) return 0; + #ifdef WITH_THREAD if (PyThread_get_thread_ident() != main_thread) return 0; #endif + + /* + * The is_stripped variable is meant to speed up the calls to + * PyErr_CheckSignals (both directly or via pending calls) when no + * signal has arrived. This variable is set to 1 when a signal arrives + * and it is set to 0 here, when we know some signals arrived. This way + * we can run the registered handlers with no signals blocked. + * + * NOTE: with this approach we can have a situation where is_tripped is + * 1 but we have no more signals to handle (Handlers[i].tripped + * is 0 for every signal i). This won't do us any harm (except + * we're gonna spent some cycles for nothing). This happens when + * we receive a signal i after we zero is_tripped and before we + * check Handlers[i].tripped. + */ + is_tripped = 0; + if (!(f = (PyObject *)PyEval_GetFrame())) f = Py_None; - + for (i = 1; i < NSIG; i++) { if (Handlers[i].tripped) { PyObject *result = NULL; @@ -621,7 +642,7 @@ PyErr_CheckSignals(void) Py_DECREF(result); } } - is_tripped = 0; + return 0; } @@ -632,7 +653,7 @@ PyErr_CheckSignals(void) void PyErr_SetInterrupt(void) { - is_tripped++; + is_tripped = 1; Handlers[SIGINT].tripped = 1; Py_AddPendingCall((int (*)(void *))PyErr_CheckSignals, NULL); } |