You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1705 lines
43 KiB

Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines Remove Tools/modulator, a reference to it in the docs, and a screenshot of it. (I asked the BDFL first, and he approved removing it. The last actual bugfix to Tools/modulator was in 2001; since then all changes have been search-and-replace: string methods, whitespace fixes, etc.) ........ r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819). ........ r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line #7706: add include guards where they're missing; required for Windows CE ........ r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line #7191: describe more details of wbits parameter ........ r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line #7637: avoid repeated-concatenation antipattern in example ........ r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ........ r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line remove CVS id ........ r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line Link correction in documentation. ........ r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line rephrase ........ r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines Try to fix buildbot breakage from r78384. Thanks bitdancer and briancurtin for the help. ........ r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines These line should not be there. ........
16 years ago
Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines Remove Tools/modulator, a reference to it in the docs, and a screenshot of it. (I asked the BDFL first, and he approved removing it. The last actual bugfix to Tools/modulator was in 2001; since then all changes have been search-and-replace: string methods, whitespace fixes, etc.) ........ r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819). ........ r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line #7706: add include guards where they're missing; required for Windows CE ........ r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line #7191: describe more details of wbits parameter ........ r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line #7637: avoid repeated-concatenation antipattern in example ........ r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ........ r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line remove CVS id ........ r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line Link correction in documentation. ........ r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line rephrase ........ r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines Try to fix buildbot breakage from r78384. Thanks bitdancer and briancurtin for the help. ........ r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines These line should not be there. ........
16 years ago
Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines Remove Tools/modulator, a reference to it in the docs, and a screenshot of it. (I asked the BDFL first, and he approved removing it. The last actual bugfix to Tools/modulator was in 2001; since then all changes have been search-and-replace: string methods, whitespace fixes, etc.) ........ r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819). ........ r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line #7706: add include guards where they're missing; required for Windows CE ........ r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line #7191: describe more details of wbits parameter ........ r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line #7637: avoid repeated-concatenation antipattern in example ........ r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ........ r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line remove CVS id ........ r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line Link correction in documentation. ........ r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line rephrase ........ r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines Try to fix buildbot breakage from r78384. Thanks bitdancer and briancurtin for the help. ........ r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines These line should not be there. ........
16 years ago
Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines Remove Tools/modulator, a reference to it in the docs, and a screenshot of it. (I asked the BDFL first, and he approved removing it. The last actual bugfix to Tools/modulator was in 2001; since then all changes have been search-and-replace: string methods, whitespace fixes, etc.) ........ r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819). ........ r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line #7706: add include guards where they're missing; required for Windows CE ........ r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line #7191: describe more details of wbits parameter ........ r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line #7637: avoid repeated-concatenation antipattern in example ........ r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ........ r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line remove CVS id ........ r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line Link correction in documentation. ........ r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line rephrase ........ r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines Try to fix buildbot breakage from r78384. Thanks bitdancer and briancurtin for the help. ........ r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines These line should not be there. ........
16 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines Remove Tools/modulator, a reference to it in the docs, and a screenshot of it. (I asked the BDFL first, and he approved removing it. The last actual bugfix to Tools/modulator was in 2001; since then all changes have been search-and-replace: string methods, whitespace fixes, etc.) ........ r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819). ........ r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line #7706: add include guards where they're missing; required for Windows CE ........ r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line #7191: describe more details of wbits parameter ........ r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line #7637: avoid repeated-concatenation antipattern in example ........ r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines Manually copy patch for bug 7250 from the release26-maint branch. I suck because I did this in the wrong order and couldn't smack svnmerge into submission. ........ r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line remove CVS id ........ r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line Link correction in documentation. ........ r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line rephrase ........ r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines Try to fix buildbot breakage from r78384. Thanks bitdancer and briancurtin for the help. ........ r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines These line should not be there. ........
16 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
31 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
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... ........
18 years ago
26 years ago
22 years ago
26 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900,60902-60906,60908,60911-60917,60919-60920,60922,60926,60929-60931,60933-60935,60937,60939-60941,60943-60954,60959-60961,60963-60964,60966-60967,60971,60977,60979-60989 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60980 | georg.brandl | 2008-02-23 16:02:28 +0100 (Sat, 23 Feb 2008) | 2 lines #1492: allow overriding BaseHTTPServer's content type for error messages. ........ r60982 | georg.brandl | 2008-02-23 16:06:25 +0100 (Sat, 23 Feb 2008) | 2 lines #2165: fix test_logging failure on some machines. ........ r60983 | facundo.batista | 2008-02-23 16:07:35 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1089358. Adds the siginterrupt() function, that is just a wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt. ........ r60984 | georg.brandl | 2008-02-23 16:11:18 +0100 (Sat, 23 Feb 2008) | 2 lines #2067: file.__exit__() now calls subclasses' close() method. ........ r60985 | georg.brandl | 2008-02-23 16:19:54 +0100 (Sat, 23 Feb 2008) | 2 lines More difflib examples. Written for GHOP by Josip Dzolonga. ........ r60987 | andrew.kuchling | 2008-02-23 16:41:51 +0100 (Sat, 23 Feb 2008) | 1 line #2072: correct documentation for .rpc_paths ........ r60988 | georg.brandl | 2008-02-23 16:43:48 +0100 (Sat, 23 Feb 2008) | 2 lines #2161: Fix opcode name. ........ r60989 | andrew.kuchling | 2008-02-23 16:49:35 +0100 (Sat, 23 Feb 2008) | 2 lines #1119331: ncurses will just call exit() if the terminal name isn't found. Call setupterm() first so that we get a Python exception instead of just existing. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900,60902-60906,60908,60911-60917,60919-60920,60922,60926,60929-60931,60933-60935,60937,60939-60941,60943-60954,60959-60961,60963-60964,60966-60967,60971,60977,60979-60989 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60980 | georg.brandl | 2008-02-23 16:02:28 +0100 (Sat, 23 Feb 2008) | 2 lines #1492: allow overriding BaseHTTPServer's content type for error messages. ........ r60982 | georg.brandl | 2008-02-23 16:06:25 +0100 (Sat, 23 Feb 2008) | 2 lines #2165: fix test_logging failure on some machines. ........ r60983 | facundo.batista | 2008-02-23 16:07:35 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1089358. Adds the siginterrupt() function, that is just a wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt. ........ r60984 | georg.brandl | 2008-02-23 16:11:18 +0100 (Sat, 23 Feb 2008) | 2 lines #2067: file.__exit__() now calls subclasses' close() method. ........ r60985 | georg.brandl | 2008-02-23 16:19:54 +0100 (Sat, 23 Feb 2008) | 2 lines More difflib examples. Written for GHOP by Josip Dzolonga. ........ r60987 | andrew.kuchling | 2008-02-23 16:41:51 +0100 (Sat, 23 Feb 2008) | 1 line #2072: correct documentation for .rpc_paths ........ r60988 | georg.brandl | 2008-02-23 16:43:48 +0100 (Sat, 23 Feb 2008) | 2 lines #2161: Fix opcode name. ........ r60989 | andrew.kuchling | 2008-02-23 16:49:35 +0100 (Sat, 23 Feb 2008) | 2 lines #1119331: ncurses will just call exit() if the terminal name isn't found. Call setupterm() first so that we get a Python exception instead of just existing. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900,60902-60906,60908,60911-60917,60919-60920,60922,60926,60929-60931,60933-60935,60937,60939-60941,60943-60954,60959-60961,60963-60964,60966-60967,60971,60977,60979-60989 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60980 | georg.brandl | 2008-02-23 16:02:28 +0100 (Sat, 23 Feb 2008) | 2 lines #1492: allow overriding BaseHTTPServer's content type for error messages. ........ r60982 | georg.brandl | 2008-02-23 16:06:25 +0100 (Sat, 23 Feb 2008) | 2 lines #2165: fix test_logging failure on some machines. ........ r60983 | facundo.batista | 2008-02-23 16:07:35 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1089358. Adds the siginterrupt() function, that is just a wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt. ........ r60984 | georg.brandl | 2008-02-23 16:11:18 +0100 (Sat, 23 Feb 2008) | 2 lines #2067: file.__exit__() now calls subclasses' close() method. ........ r60985 | georg.brandl | 2008-02-23 16:19:54 +0100 (Sat, 23 Feb 2008) | 2 lines More difflib examples. Written for GHOP by Josip Dzolonga. ........ r60987 | andrew.kuchling | 2008-02-23 16:41:51 +0100 (Sat, 23 Feb 2008) | 1 line #2072: correct documentation for .rpc_paths ........ r60988 | georg.brandl | 2008-02-23 16:43:48 +0100 (Sat, 23 Feb 2008) | 2 lines #2161: Fix opcode name. ........ r60989 | andrew.kuchling | 2008-02-23 16:49:35 +0100 (Sat, 23 Feb 2008) | 2 lines #1119331: ncurses will just call exit() if the terminal name isn't found. Call setupterm() first so that we get a Python exception instead of just existing. ........
18 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900,60902-60906,60908,60911-60917,60919-60920,60922,60926,60929-60931,60933-60935,60937,60939-60941,60943-60954,60959-60961,60963-60964,60966-60967,60971,60977,60979-60989 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60980 | georg.brandl | 2008-02-23 16:02:28 +0100 (Sat, 23 Feb 2008) | 2 lines #1492: allow overriding BaseHTTPServer's content type for error messages. ........ r60982 | georg.brandl | 2008-02-23 16:06:25 +0100 (Sat, 23 Feb 2008) | 2 lines #2165: fix test_logging failure on some machines. ........ r60983 | facundo.batista | 2008-02-23 16:07:35 +0100 (Sat, 23 Feb 2008) | 6 lines Issue 1089358. Adds the siginterrupt() function, that is just a wrapper around the system call with the same name. Also added test cases, doc changes and NEWS entry. Thanks Jason and Ralf Schmitt. ........ r60984 | georg.brandl | 2008-02-23 16:11:18 +0100 (Sat, 23 Feb 2008) | 2 lines #2067: file.__exit__() now calls subclasses' close() method. ........ r60985 | georg.brandl | 2008-02-23 16:19:54 +0100 (Sat, 23 Feb 2008) | 2 lines More difflib examples. Written for GHOP by Josip Dzolonga. ........ r60987 | andrew.kuchling | 2008-02-23 16:41:51 +0100 (Sat, 23 Feb 2008) | 1 line #2072: correct documentation for .rpc_paths ........ r60988 | georg.brandl | 2008-02-23 16:43:48 +0100 (Sat, 23 Feb 2008) | 2 lines #2161: Fix opcode name. ........ r60989 | andrew.kuchling | 2008-02-23 16:49:35 +0100 (Sat, 23 Feb 2008) | 2 lines #1119331: ncurses will just call exit() if the terminal name isn't found. Call setupterm() first so that we get a Python exception instead of just existing. ........
18 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
12 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........
18 years ago
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... ........
18 years ago
  1. /* Signal module -- many thanks to Lance Ellinghaus */
  2. /* XXX Signals should be recorded per thread, now we have thread state. */
  3. #include "Python.h"
  4. #include "pycore_atomic.h"
  5. #ifndef MS_WINDOWS
  6. #include "posixmodule.h"
  7. #endif
  8. #ifdef MS_WINDOWS
  9. #include "socketmodule.h" /* needed for SOCKET_T */
  10. #endif
  11. #ifdef MS_WINDOWS
  12. #include <windows.h>
  13. #ifdef HAVE_PROCESS_H
  14. #include <process.h>
  15. #endif
  16. #endif
  17. #ifdef HAVE_SIGNAL_H
  18. #include <signal.h>
  19. #endif
  20. #ifdef HAVE_SYS_STAT_H
  21. #include <sys/stat.h>
  22. #endif
  23. #ifdef HAVE_SYS_TIME_H
  24. #include <sys/time.h>
  25. #endif
  26. #if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
  27. # define PYPTHREAD_SIGMASK
  28. #endif
  29. #if defined(PYPTHREAD_SIGMASK) && defined(HAVE_PTHREAD_H)
  30. # include <pthread.h>
  31. #endif
  32. #ifndef SIG_ERR
  33. #define SIG_ERR ((PyOS_sighandler_t)(-1))
  34. #endif
  35. #ifndef NSIG
  36. # if defined(_NSIG)
  37. # define NSIG _NSIG /* For BSD/SysV */
  38. # elif defined(_SIGMAX)
  39. # define NSIG (_SIGMAX + 1) /* For QNX */
  40. # elif defined(SIGMAX)
  41. # define NSIG (SIGMAX + 1) /* For djgpp */
  42. # else
  43. # define NSIG 64 /* Use a reasonable default value */
  44. # endif
  45. #endif
  46. #include "clinic/signalmodule.c.h"
  47. /*[clinic input]
  48. module signal
  49. [clinic start generated code]*/
  50. /*[clinic end generated code: output=da39a3ee5e6b4b0d input=b0301a3bde5fe9d3]*/
  51. /*[python input]
  52. class sigset_t_converter(CConverter):
  53. type = 'sigset_t'
  54. converter = '_Py_Sigset_Converter'
  55. [python start generated code]*/
  56. /*[python end generated code: output=da39a3ee5e6b4b0d input=b5689d14466b6823]*/
  57. /*
  58. NOTES ON THE INTERACTION BETWEEN SIGNALS AND THREADS
  59. When threads are supported, we want the following semantics:
  60. - only the main thread can set a signal handler
  61. - any thread can get a signal handler
  62. - signals are only delivered to the main thread
  63. I.e. we don't support "synchronous signals" like SIGFPE (catching
  64. this doesn't make much sense in Python anyway) nor do we support
  65. signals as a means of inter-thread communication, since not all
  66. thread implementations support that (at least our thread library
  67. doesn't).
  68. We still have the problem that in some implementations signals
  69. generated by the keyboard (e.g. SIGINT) are delivered to all
  70. threads (e.g. SGI), while in others (e.g. Solaris) such signals are
  71. delivered to one random thread (an intermediate possibility would
  72. be to deliver it to the main thread -- POSIX?). For now, we have
  73. a working implementation that works in all three cases -- the
  74. handler ignores signals if getpid() isn't the same as in the main
  75. thread. XXX This is a hack.
  76. */
  77. #include <sys/types.h> /* For pid_t */
  78. #include "pythread.h"
  79. static unsigned long main_thread;
  80. static pid_t main_pid;
  81. static volatile struct {
  82. _Py_atomic_int tripped;
  83. PyObject *func;
  84. } Handlers[NSIG];
  85. #ifdef MS_WINDOWS
  86. #define INVALID_FD ((SOCKET_T)-1)
  87. static volatile struct {
  88. SOCKET_T fd;
  89. int warn_on_full_buffer;
  90. int use_send;
  91. } wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1, .use_send = 0};
  92. #else
  93. #define INVALID_FD (-1)
  94. static volatile struct {
  95. sig_atomic_t fd;
  96. int warn_on_full_buffer;
  97. } wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1};
  98. #endif
  99. /* Speed up sigcheck() when none tripped */
  100. static _Py_atomic_int is_tripped;
  101. static PyObject *DefaultHandler;
  102. static PyObject *IgnoreHandler;
  103. static PyObject *IntHandler;
  104. #ifdef MS_WINDOWS
  105. static HANDLE sigint_event = NULL;
  106. #endif
  107. #ifdef HAVE_GETITIMER
  108. static PyObject *ItimerError;
  109. /* auxiliary functions for setitimer */
  110. static int
  111. timeval_from_double(PyObject *obj, struct timeval *tv)
  112. {
  113. if (obj == NULL) {
  114. tv->tv_sec = 0;
  115. tv->tv_usec = 0;
  116. return 0;
  117. }
  118. _PyTime_t t;
  119. if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_CEILING) < 0) {
  120. return -1;
  121. }
  122. return _PyTime_AsTimeval(t, tv, _PyTime_ROUND_CEILING);
  123. }
  124. Py_LOCAL_INLINE(double)
  125. double_from_timeval(struct timeval *tv)
  126. {
  127. return tv->tv_sec + (double)(tv->tv_usec / 1000000.0);
  128. }
  129. static PyObject *
  130. itimer_retval(struct itimerval *iv)
  131. {
  132. PyObject *r, *v;
  133. r = PyTuple_New(2);
  134. if (r == NULL)
  135. return NULL;
  136. if(!(v = PyFloat_FromDouble(double_from_timeval(&iv->it_value)))) {
  137. Py_DECREF(r);
  138. return NULL;
  139. }
  140. PyTuple_SET_ITEM(r, 0, v);
  141. if(!(v = PyFloat_FromDouble(double_from_timeval(&iv->it_interval)))) {
  142. Py_DECREF(r);
  143. return NULL;
  144. }
  145. PyTuple_SET_ITEM(r, 1, v);
  146. return r;
  147. }
  148. #endif
  149. static PyObject *
  150. signal_default_int_handler(PyObject *self, PyObject *args)
  151. {
  152. PyErr_SetNone(PyExc_KeyboardInterrupt);
  153. return NULL;
  154. }
  155. PyDoc_STRVAR(default_int_handler_doc,
  156. "default_int_handler(...)\n\
  157. \n\
  158. The default handler for SIGINT installed by Python.\n\
  159. It raises KeyboardInterrupt.");
  160. static int
  161. report_wakeup_write_error(void *data)
  162. {
  163. int save_errno = errno;
  164. errno = (int) (intptr_t) data;
  165. PyErr_SetFromErrno(PyExc_OSError);
  166. PySys_WriteStderr("Exception ignored when trying to write to the "
  167. "signal wakeup fd:\n");
  168. PyErr_WriteUnraisable(NULL);
  169. errno = save_errno;
  170. return 0;
  171. }
  172. #ifdef MS_WINDOWS
  173. static int
  174. report_wakeup_send_error(void* data)
  175. {
  176. /* PyErr_SetExcFromWindowsErr() invokes FormatMessage() which
  177. recognizes the error codes used by both GetLastError() and
  178. WSAGetLastError */
  179. PyErr_SetExcFromWindowsErr(PyExc_OSError, (int) (intptr_t) data);
  180. PySys_WriteStderr("Exception ignored when trying to send to the "
  181. "signal wakeup fd:\n");
  182. PyErr_WriteUnraisable(NULL);
  183. return 0;
  184. }
  185. #endif /* MS_WINDOWS */
  186. static void
  187. trip_signal(int sig_num)
  188. {
  189. unsigned char byte;
  190. int fd;
  191. Py_ssize_t rc;
  192. _Py_atomic_store_relaxed(&Handlers[sig_num].tripped, 1);
  193. /* Set is_tripped after setting .tripped, as it gets
  194. cleared in PyErr_CheckSignals() before .tripped. */
  195. _Py_atomic_store(&is_tripped, 1);
  196. /* Notify ceval.c */
  197. _PyEval_SignalReceived();
  198. /* And then write to the wakeup fd *after* setting all the globals and
  199. doing the _PyEval_SignalReceived. We used to write to the wakeup fd
  200. and then set the flag, but this allowed the following sequence of events
  201. (especially on windows, where trip_signal may run in a new thread):
  202. - main thread blocks on select([wakeup.fd], ...)
  203. - signal arrives
  204. - trip_signal writes to the wakeup fd
  205. - the main thread wakes up
  206. - the main thread checks the signal flags, sees that they're unset
  207. - the main thread empties the wakeup fd
  208. - the main thread goes back to sleep
  209. - trip_signal sets the flags to request the Python-level signal handler
  210. be run
  211. - the main thread doesn't notice, because it's asleep
  212. See bpo-30038 for more details.
  213. */
  214. #ifdef MS_WINDOWS
  215. fd = Py_SAFE_DOWNCAST(wakeup.fd, SOCKET_T, int);
  216. #else
  217. fd = wakeup.fd;
  218. #endif
  219. if (fd != INVALID_FD) {
  220. byte = (unsigned char)sig_num;
  221. #ifdef MS_WINDOWS
  222. if (wakeup.use_send) {
  223. rc = send(fd, &byte, 1, 0);
  224. if (rc < 0) {
  225. int last_error = GetLastError();
  226. if (wakeup.warn_on_full_buffer ||
  227. last_error != WSAEWOULDBLOCK)
  228. {
  229. /* Py_AddPendingCall() isn't signal-safe, but we
  230. still use it for this exceptional case. */
  231. Py_AddPendingCall(report_wakeup_send_error,
  232. (void *)(intptr_t) last_error);
  233. }
  234. }
  235. }
  236. else
  237. #endif
  238. {
  239. /* _Py_write_noraise() retries write() if write() is interrupted by
  240. a signal (fails with EINTR). */
  241. rc = _Py_write_noraise(fd, &byte, 1);
  242. if (rc < 0) {
  243. if (wakeup.warn_on_full_buffer ||
  244. (errno != EWOULDBLOCK && errno != EAGAIN))
  245. {
  246. /* Py_AddPendingCall() isn't signal-safe, but we
  247. still use it for this exceptional case. */
  248. Py_AddPendingCall(report_wakeup_write_error,
  249. (void *)(intptr_t)errno);
  250. }
  251. }
  252. }
  253. }
  254. }
  255. static void
  256. signal_handler(int sig_num)
  257. {
  258. int save_errno = errno;
  259. /* See NOTES section above */
  260. if (getpid() == main_pid)
  261. {
  262. trip_signal(sig_num);
  263. }
  264. #ifndef HAVE_SIGACTION
  265. #ifdef SIGCHLD
  266. /* To avoid infinite recursion, this signal remains
  267. reset until explicit re-instated.
  268. Don't clear the 'func' field as it is our pointer
  269. to the Python handler... */
  270. if (sig_num != SIGCHLD)
  271. #endif
  272. /* If the handler was not set up with sigaction, reinstall it. See
  273. * Python/pylifecycle.c for the implementation of PyOS_setsig which
  274. * makes this true. See also issue8354. */
  275. PyOS_setsig(sig_num, signal_handler);
  276. #endif
  277. /* Issue #10311: asynchronously executing signal handlers should not
  278. mutate errno under the feet of unsuspecting C code. */
  279. errno = save_errno;
  280. #ifdef MS_WINDOWS
  281. if (sig_num == SIGINT)
  282. SetEvent(sigint_event);
  283. #endif
  284. }
  285. #ifdef HAVE_ALARM
  286. /*[clinic input]
  287. signal.alarm -> long
  288. seconds: int
  289. /
  290. Arrange for SIGALRM to arrive after the given number of seconds.
  291. [clinic start generated code]*/
  292. static long
  293. signal_alarm_impl(PyObject *module, int seconds)
  294. /*[clinic end generated code: output=144232290814c298 input=0d5e97e0e6f39e86]*/
  295. {
  296. /* alarm() returns the number of seconds remaining */
  297. return (long)alarm(seconds);
  298. }
  299. #endif
  300. #ifdef HAVE_PAUSE
  301. /*[clinic input]
  302. signal.pause
  303. Wait until a signal arrives.
  304. [clinic start generated code]*/
  305. static PyObject *
  306. signal_pause_impl(PyObject *module)
  307. /*[clinic end generated code: output=391656788b3c3929 input=f03de0f875752062]*/
  308. {
  309. Py_BEGIN_ALLOW_THREADS
  310. (void)pause();
  311. Py_END_ALLOW_THREADS
  312. /* make sure that any exceptions that got raised are propagated
  313. * back into Python
  314. */
  315. if (PyErr_CheckSignals())
  316. return NULL;
  317. Py_RETURN_NONE;
  318. }
  319. #endif
  320. /*[clinic input]
  321. signal.signal
  322. signalnum: int
  323. handler: object
  324. /
  325. Set the action for the given signal.
  326. The action can be SIG_DFL, SIG_IGN, or a callable Python object.
  327. The previous action is returned. See getsignal() for possible return values.
  328. *** IMPORTANT NOTICE ***
  329. A signal handler function is called with two arguments:
  330. the first is the signal number, the second is the interrupted stack frame.
  331. [clinic start generated code]*/
  332. static PyObject *
  333. signal_signal_impl(PyObject *module, int signalnum, PyObject *handler)
  334. /*[clinic end generated code: output=b44cfda43780f3a1 input=deee84af5fa0432c]*/
  335. {
  336. PyObject *old_handler;
  337. void (*func)(int);
  338. #ifdef MS_WINDOWS
  339. /* Validate that signalnum is one of the allowable signals */
  340. switch (signalnum) {
  341. case SIGABRT: break;
  342. #ifdef SIGBREAK
  343. /* Issue #10003: SIGBREAK is not documented as permitted, but works
  344. and corresponds to CTRL_BREAK_EVENT. */
  345. case SIGBREAK: break;
  346. #endif
  347. case SIGFPE: break;
  348. case SIGILL: break;
  349. case SIGINT: break;
  350. case SIGSEGV: break;
  351. case SIGTERM: break;
  352. default:
  353. PyErr_SetString(PyExc_ValueError, "invalid signal value");
  354. return NULL;
  355. }
  356. #endif
  357. if (PyThread_get_thread_ident() != main_thread) {
  358. PyErr_SetString(PyExc_ValueError,
  359. "signal only works in main thread");
  360. return NULL;
  361. }
  362. if (signalnum < 1 || signalnum >= NSIG) {
  363. PyErr_SetString(PyExc_ValueError,
  364. "signal number out of range");
  365. return NULL;
  366. }
  367. if (handler == IgnoreHandler)
  368. func = SIG_IGN;
  369. else if (handler == DefaultHandler)
  370. func = SIG_DFL;
  371. else if (!PyCallable_Check(handler)) {
  372. PyErr_SetString(PyExc_TypeError,
  373. "signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object");
  374. return NULL;
  375. }
  376. else
  377. func = signal_handler;
  378. /* Check for pending signals before changing signal handler */
  379. if (PyErr_CheckSignals()) {
  380. return NULL;
  381. }
  382. if (PyOS_setsig(signalnum, func) == SIG_ERR) {
  383. PyErr_SetFromErrno(PyExc_OSError);
  384. return NULL;
  385. }
  386. old_handler = Handlers[signalnum].func;
  387. Py_INCREF(handler);
  388. Handlers[signalnum].func = handler;
  389. if (old_handler != NULL)
  390. return old_handler;
  391. else
  392. Py_RETURN_NONE;
  393. }
  394. /*[clinic input]
  395. signal.getsignal
  396. signalnum: int
  397. /
  398. Return the current action for the given signal.
  399. The return value can be:
  400. SIG_IGN -- if the signal is being ignored
  401. SIG_DFL -- if the default action for the signal is in effect
  402. None -- if an unknown handler is in effect
  403. anything else -- the callable Python object used as a handler
  404. [clinic start generated code]*/
  405. static PyObject *
  406. signal_getsignal_impl(PyObject *module, int signalnum)
  407. /*[clinic end generated code: output=35b3e0e796fd555e input=ac23a00f19dfa509]*/
  408. {
  409. PyObject *old_handler;
  410. if (signalnum < 1 || signalnum >= NSIG) {
  411. PyErr_SetString(PyExc_ValueError,
  412. "signal number out of range");
  413. return NULL;
  414. }
  415. old_handler = Handlers[signalnum].func;
  416. if (old_handler != NULL) {
  417. Py_INCREF(old_handler);
  418. return old_handler;
  419. }
  420. else {
  421. Py_RETURN_NONE;
  422. }
  423. }
  424. /*[clinic input]
  425. signal.strsignal
  426. signalnum: int
  427. /
  428. Return the system description of the given signal.
  429. The return values can be such as "Interrupt", "Segmentation fault", etc.
  430. Returns None if the signal is not recognized.
  431. [clinic start generated code]*/
  432. static PyObject *
  433. signal_strsignal_impl(PyObject *module, int signalnum)
  434. /*[clinic end generated code: output=44e12e1e3b666261 input=b77914b03f856c74]*/
  435. {
  436. char *res;
  437. if (signalnum < 1 || signalnum >= NSIG) {
  438. PyErr_SetString(PyExc_ValueError,
  439. "signal number out of range");
  440. return NULL;
  441. }
  442. #ifndef HAVE_STRSIGNAL
  443. switch (signalnum) {
  444. /* Though being a UNIX, HP-UX does not provide strsignal(3). */
  445. #ifndef MS_WINDOWS
  446. case SIGHUP:
  447. res = "Hangup";
  448. break;
  449. case SIGALRM:
  450. res = "Alarm clock";
  451. break;
  452. case SIGPIPE:
  453. res = "Broken pipe";
  454. break;
  455. case SIGQUIT:
  456. res = "Quit";
  457. break;
  458. case SIGCHLD:
  459. res = "Child exited";
  460. break;
  461. #endif
  462. /* Custom redefinition of POSIX signals allowed on Windows. */
  463. case SIGINT:
  464. res = "Interrupt";
  465. break;
  466. case SIGILL:
  467. res = "Illegal instruction";
  468. break;
  469. case SIGABRT:
  470. res = "Aborted";
  471. break;
  472. case SIGFPE:
  473. res = "Floating point exception";
  474. break;
  475. case SIGSEGV:
  476. res = "Segmentation fault";
  477. break;
  478. case SIGTERM:
  479. res = "Terminated";
  480. break;
  481. default:
  482. Py_RETURN_NONE;
  483. }
  484. #else
  485. errno = 0;
  486. res = strsignal(signalnum);
  487. if (errno || res == NULL || strstr(res, "Unknown signal") != NULL)
  488. Py_RETURN_NONE;
  489. #endif
  490. return Py_BuildValue("s", res);
  491. }
  492. #ifdef HAVE_SIGINTERRUPT
  493. /*[clinic input]
  494. signal.siginterrupt
  495. signalnum: int
  496. flag: int
  497. /
  498. Change system call restart behaviour.
  499. If flag is False, system calls will be restarted when interrupted by
  500. signal sig, else system calls will be interrupted.
  501. [clinic start generated code]*/
  502. static PyObject *
  503. signal_siginterrupt_impl(PyObject *module, int signalnum, int flag)
  504. /*[clinic end generated code: output=063816243d85dd19 input=4160acacca3e2099]*/
  505. {
  506. if (signalnum < 1 || signalnum >= NSIG) {
  507. PyErr_SetString(PyExc_ValueError,
  508. "signal number out of range");
  509. return NULL;
  510. }
  511. if (siginterrupt(signalnum, flag)<0) {
  512. PyErr_SetFromErrno(PyExc_OSError);
  513. return NULL;
  514. }
  515. Py_RETURN_NONE;
  516. }
  517. #endif
  518. static PyObject*
  519. signal_set_wakeup_fd(PyObject *self, PyObject *args, PyObject *kwds)
  520. {
  521. struct _Py_stat_struct status;
  522. static char *kwlist[] = {
  523. "", "warn_on_full_buffer", NULL,
  524. };
  525. int warn_on_full_buffer = 1;
  526. #ifdef MS_WINDOWS
  527. PyObject *fdobj;
  528. SOCKET_T sockfd, old_sockfd;
  529. int res;
  530. int res_size = sizeof res;
  531. PyObject *mod;
  532. int is_socket;
  533. if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|$p:set_wakeup_fd", kwlist,
  534. &fdobj, &warn_on_full_buffer))
  535. return NULL;
  536. sockfd = PyLong_AsSocket_t(fdobj);
  537. if (sockfd == (SOCKET_T)(-1) && PyErr_Occurred())
  538. return NULL;
  539. #else
  540. int fd, old_fd;
  541. if (!PyArg_ParseTupleAndKeywords(args, kwds, "i|$p:set_wakeup_fd", kwlist,
  542. &fd, &warn_on_full_buffer))
  543. return NULL;
  544. #endif
  545. if (PyThread_get_thread_ident() != main_thread) {
  546. PyErr_SetString(PyExc_ValueError,
  547. "set_wakeup_fd only works in main thread");
  548. return NULL;
  549. }
  550. #ifdef MS_WINDOWS
  551. is_socket = 0;
  552. if (sockfd != INVALID_FD) {
  553. /* Import the _socket module to call WSAStartup() */
  554. mod = PyImport_ImportModuleNoBlock("_socket");
  555. if (mod == NULL)
  556. return NULL;
  557. Py_DECREF(mod);
  558. /* test the socket */
  559. if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR,
  560. (char *)&res, &res_size) != 0) {
  561. int fd, err;
  562. err = WSAGetLastError();
  563. if (err != WSAENOTSOCK) {
  564. PyErr_SetExcFromWindowsErr(PyExc_OSError, err);
  565. return NULL;
  566. }
  567. fd = (int)sockfd;
  568. if ((SOCKET_T)fd != sockfd) {
  569. PyErr_SetString(PyExc_ValueError, "invalid fd");
  570. return NULL;
  571. }
  572. if (_Py_fstat(fd, &status) != 0)
  573. return NULL;
  574. /* on Windows, a file cannot be set to non-blocking mode */
  575. }
  576. else {
  577. is_socket = 1;
  578. /* Windows does not provide a function to test if a socket
  579. is in non-blocking mode */
  580. }
  581. }
  582. old_sockfd = wakeup.fd;
  583. wakeup.fd = sockfd;
  584. wakeup.warn_on_full_buffer = warn_on_full_buffer;
  585. wakeup.use_send = is_socket;
  586. if (old_sockfd != INVALID_FD)
  587. return PyLong_FromSocket_t(old_sockfd);
  588. else
  589. return PyLong_FromLong(-1);
  590. #else
  591. if (fd != -1) {
  592. int blocking;
  593. if (_Py_fstat(fd, &status) != 0)
  594. return NULL;
  595. blocking = _Py_get_blocking(fd);
  596. if (blocking < 0)
  597. return NULL;
  598. if (blocking) {
  599. PyErr_Format(PyExc_ValueError,
  600. "the fd %i must be in non-blocking mode",
  601. fd);
  602. return NULL;
  603. }
  604. }
  605. old_fd = wakeup.fd;
  606. wakeup.fd = fd;
  607. wakeup.warn_on_full_buffer = warn_on_full_buffer;
  608. return PyLong_FromLong(old_fd);
  609. #endif
  610. }
  611. PyDoc_STRVAR(set_wakeup_fd_doc,
  612. "set_wakeup_fd(fd, *, warn_on_full_buffer=True) -> fd\n\
  613. \n\
  614. Sets the fd to be written to (with the signal number) when a signal\n\
  615. comes in. A library can use this to wakeup select or poll.\n\
  616. The previous fd or -1 is returned.\n\
  617. \n\
  618. The fd must be non-blocking.");
  619. /* C API for the same, without all the error checking */
  620. int
  621. PySignal_SetWakeupFd(int fd)
  622. {
  623. int old_fd;
  624. if (fd < 0)
  625. fd = -1;
  626. #ifdef MS_WINDOWS
  627. old_fd = Py_SAFE_DOWNCAST(wakeup.fd, SOCKET_T, int);
  628. #else
  629. old_fd = wakeup.fd;
  630. #endif
  631. wakeup.fd = fd;
  632. wakeup.warn_on_full_buffer = 1;
  633. return old_fd;
  634. }
  635. #ifdef HAVE_SETITIMER
  636. /*[clinic input]
  637. signal.setitimer
  638. which: int
  639. seconds: object
  640. interval: object(c_default="NULL") = 0.0
  641. /
  642. Sets given itimer (one of ITIMER_REAL, ITIMER_VIRTUAL or ITIMER_PROF).
  643. The timer will fire after value seconds and after that every interval seconds.
  644. The itimer can be cleared by setting seconds to zero.
  645. Returns old values as a tuple: (delay, interval).
  646. [clinic start generated code]*/
  647. static PyObject *
  648. signal_setitimer_impl(PyObject *module, int which, PyObject *seconds,
  649. PyObject *interval)
  650. /*[clinic end generated code: output=65f9dcbddc35527b input=de43daf194e6f66f]*/
  651. {
  652. struct itimerval new, old;
  653. if (timeval_from_double(seconds, &new.it_value) < 0) {
  654. return NULL;
  655. }
  656. if (timeval_from_double(interval, &new.it_interval) < 0) {
  657. return NULL;
  658. }
  659. /* Let OS check "which" value */
  660. if (setitimer(which, &new, &old) != 0) {
  661. PyErr_SetFromErrno(ItimerError);
  662. return NULL;
  663. }
  664. return itimer_retval(&old);
  665. }
  666. #endif
  667. #ifdef HAVE_GETITIMER
  668. /*[clinic input]
  669. signal.getitimer
  670. which: int
  671. /
  672. Returns current value of given itimer.
  673. [clinic start generated code]*/
  674. static PyObject *
  675. signal_getitimer_impl(PyObject *module, int which)
  676. /*[clinic end generated code: output=9e053175d517db40 input=f7d21d38f3490627]*/
  677. {
  678. struct itimerval old;
  679. if (getitimer(which, &old) != 0) {
  680. PyErr_SetFromErrno(ItimerError);
  681. return NULL;
  682. }
  683. return itimer_retval(&old);
  684. }
  685. #endif
  686. #if defined(PYPTHREAD_SIGMASK) || defined(HAVE_SIGPENDING)
  687. static PyObject*
  688. sigset_to_set(sigset_t mask)
  689. {
  690. PyObject *signum, *result;
  691. int sig;
  692. result = PySet_New(0);
  693. if (result == NULL)
  694. return NULL;
  695. for (sig = 1; sig < NSIG; sig++) {
  696. if (sigismember(&mask, sig) != 1)
  697. continue;
  698. /* Handle the case where it is a member by adding the signal to
  699. the result list. Ignore the other cases because they mean the
  700. signal isn't a member of the mask or the signal was invalid,
  701. and an invalid signal must have been our fault in constructing
  702. the loop boundaries. */
  703. signum = PyLong_FromLong(sig);
  704. if (signum == NULL) {
  705. Py_DECREF(result);
  706. return NULL;
  707. }
  708. if (PySet_Add(result, signum) == -1) {
  709. Py_DECREF(signum);
  710. Py_DECREF(result);
  711. return NULL;
  712. }
  713. Py_DECREF(signum);
  714. }
  715. return result;
  716. }
  717. #endif
  718. #ifdef PYPTHREAD_SIGMASK
  719. /*[clinic input]
  720. signal.pthread_sigmask
  721. how: int
  722. mask: sigset_t
  723. /
  724. Fetch and/or change the signal mask of the calling thread.
  725. [clinic start generated code]*/
  726. static PyObject *
  727. signal_pthread_sigmask_impl(PyObject *module, int how, sigset_t mask)
  728. /*[clinic end generated code: output=0562c0fb192981a8 input=85bcebda442fa77f]*/
  729. {
  730. sigset_t previous;
  731. int err;
  732. err = pthread_sigmask(how, &mask, &previous);
  733. if (err != 0) {
  734. errno = err;
  735. PyErr_SetFromErrno(PyExc_OSError);
  736. return NULL;
  737. }
  738. /* if signals was unblocked, signal handlers have been called */
  739. if (PyErr_CheckSignals())
  740. return NULL;
  741. return sigset_to_set(previous);
  742. }
  743. #endif /* #ifdef PYPTHREAD_SIGMASK */
  744. #ifdef HAVE_SIGPENDING
  745. /*[clinic input]
  746. signal.sigpending
  747. Examine pending signals.
  748. Returns a set of signal numbers that are pending for delivery to
  749. the calling thread.
  750. [clinic start generated code]*/
  751. static PyObject *
  752. signal_sigpending_impl(PyObject *module)
  753. /*[clinic end generated code: output=53375ffe89325022 input=e0036c016f874e29]*/
  754. {
  755. int err;
  756. sigset_t mask;
  757. err = sigpending(&mask);
  758. if (err)
  759. return PyErr_SetFromErrno(PyExc_OSError);
  760. return sigset_to_set(mask);
  761. }
  762. #endif /* #ifdef HAVE_SIGPENDING */
  763. #ifdef HAVE_SIGWAIT
  764. /*[clinic input]
  765. signal.sigwait
  766. sigset: sigset_t
  767. /
  768. Wait for a signal.
  769. Suspend execution of the calling thread until the delivery of one of the
  770. signals specified in the signal set sigset. The function accepts the signal
  771. and returns the signal number.
  772. [clinic start generated code]*/
  773. static PyObject *
  774. signal_sigwait_impl(PyObject *module, sigset_t sigset)
  775. /*[clinic end generated code: output=f43770699d682f96 input=a6fbd47b1086d119]*/
  776. {
  777. int err, signum;
  778. Py_BEGIN_ALLOW_THREADS
  779. err = sigwait(&sigset, &signum);
  780. Py_END_ALLOW_THREADS
  781. if (err) {
  782. errno = err;
  783. return PyErr_SetFromErrno(PyExc_OSError);
  784. }
  785. return PyLong_FromLong(signum);
  786. }
  787. #endif /* #ifdef HAVE_SIGWAIT */
  788. #if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
  789. /*[clinic input]
  790. signal.valid_signals
  791. Return a set of valid signal numbers on this platform.
  792. The signal numbers returned by this function can be safely passed to
  793. functions like `pthread_sigmask`.
  794. [clinic start generated code]*/
  795. static PyObject *
  796. signal_valid_signals_impl(PyObject *module)
  797. /*[clinic end generated code: output=1609cffbcfcf1314 input=86a3717ff25288f2]*/
  798. {
  799. #ifdef MS_WINDOWS
  800. #ifdef SIGBREAK
  801. PyObject *tup = Py_BuildValue("(iiiiiii)", SIGABRT, SIGBREAK, SIGFPE,
  802. SIGILL, SIGINT, SIGSEGV, SIGTERM);
  803. #else
  804. PyObject *tup = Py_BuildValue("(iiiiii)", SIGABRT, SIGFPE, SIGILL,
  805. SIGINT, SIGSEGV, SIGTERM);
  806. #endif
  807. if (tup == NULL) {
  808. return NULL;
  809. }
  810. PyObject *set = PySet_New(tup);
  811. Py_DECREF(tup);
  812. return set;
  813. #else
  814. sigset_t mask;
  815. if (sigemptyset(&mask) || sigfillset(&mask)) {
  816. return PyErr_SetFromErrno(PyExc_OSError);
  817. }
  818. return sigset_to_set(mask);
  819. #endif
  820. }
  821. #endif /* #if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS) */
  822. #if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
  823. static int initialized;
  824. static PyStructSequence_Field struct_siginfo_fields[] = {
  825. {"si_signo", "signal number"},
  826. {"si_code", "signal code"},
  827. {"si_errno", "errno associated with this signal"},
  828. {"si_pid", "sending process ID"},
  829. {"si_uid", "real user ID of sending process"},
  830. {"si_status", "exit value or signal"},
  831. {"si_band", "band event for SIGPOLL"},
  832. {0}
  833. };
  834. PyDoc_STRVAR(struct_siginfo__doc__,
  835. "struct_siginfo: Result from sigwaitinfo or sigtimedwait.\n\n\
  836. This object may be accessed either as a tuple of\n\
  837. (si_signo, si_code, si_errno, si_pid, si_uid, si_status, si_band),\n\
  838. or via the attributes si_signo, si_code, and so on.");
  839. static PyStructSequence_Desc struct_siginfo_desc = {
  840. "signal.struct_siginfo", /* name */
  841. struct_siginfo__doc__, /* doc */
  842. struct_siginfo_fields, /* fields */
  843. 7 /* n_in_sequence */
  844. };
  845. static PyTypeObject SiginfoType;
  846. static PyObject *
  847. fill_siginfo(siginfo_t *si)
  848. {
  849. PyObject *result = PyStructSequence_New(&SiginfoType);
  850. if (!result)
  851. return NULL;
  852. PyStructSequence_SET_ITEM(result, 0, PyLong_FromLong((long)(si->si_signo)));
  853. PyStructSequence_SET_ITEM(result, 1, PyLong_FromLong((long)(si->si_code)));
  854. PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong((long)(si->si_errno)));
  855. PyStructSequence_SET_ITEM(result, 3, PyLong_FromPid(si->si_pid));
  856. PyStructSequence_SET_ITEM(result, 4, _PyLong_FromUid(si->si_uid));
  857. PyStructSequence_SET_ITEM(result, 5,
  858. PyLong_FromLong((long)(si->si_status)));
  859. #ifdef HAVE_SIGINFO_T_SI_BAND
  860. PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
  861. #else
  862. PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(0L));
  863. #endif
  864. if (PyErr_Occurred()) {
  865. Py_DECREF(result);
  866. return NULL;
  867. }
  868. return result;
  869. }
  870. #endif
  871. #ifdef HAVE_SIGWAITINFO
  872. /*[clinic input]
  873. signal.sigwaitinfo
  874. sigset: sigset_t
  875. /
  876. Wait synchronously until one of the signals in *sigset* is delivered.
  877. Returns a struct_siginfo containing information about the signal.
  878. [clinic start generated code]*/
  879. static PyObject *
  880. signal_sigwaitinfo_impl(PyObject *module, sigset_t sigset)
  881. /*[clinic end generated code: output=1eb2f1fa236fdbca input=3d1a7e1f27fc664c]*/
  882. {
  883. siginfo_t si;
  884. int err;
  885. int async_err = 0;
  886. do {
  887. Py_BEGIN_ALLOW_THREADS
  888. err = sigwaitinfo(&sigset, &si);
  889. Py_END_ALLOW_THREADS
  890. } while (err == -1
  891. && errno == EINTR && !(async_err = PyErr_CheckSignals()));
  892. if (err == -1)
  893. return (!async_err) ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
  894. return fill_siginfo(&si);
  895. }
  896. #endif /* #ifdef HAVE_SIGWAITINFO */
  897. #ifdef HAVE_SIGTIMEDWAIT
  898. /*[clinic input]
  899. signal.sigtimedwait
  900. sigset: sigset_t
  901. timeout as timeout_obj: object
  902. /
  903. Like sigwaitinfo(), but with a timeout.
  904. The timeout is specified in seconds, with floating point numbers allowed.
  905. [clinic start generated code]*/
  906. static PyObject *
  907. signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
  908. PyObject *timeout_obj)
  909. /*[clinic end generated code: output=59c8971e8ae18a64 input=87fd39237cf0b7ba]*/
  910. {
  911. struct timespec ts;
  912. siginfo_t si;
  913. int res;
  914. _PyTime_t timeout, deadline, monotonic;
  915. if (_PyTime_FromSecondsObject(&timeout,
  916. timeout_obj, _PyTime_ROUND_CEILING) < 0)
  917. return NULL;
  918. if (timeout < 0) {
  919. PyErr_SetString(PyExc_ValueError, "timeout must be non-negative");
  920. return NULL;
  921. }
  922. deadline = _PyTime_GetMonotonicClock() + timeout;
  923. do {
  924. if (_PyTime_AsTimespec(timeout, &ts) < 0)
  925. return NULL;
  926. Py_BEGIN_ALLOW_THREADS
  927. res = sigtimedwait(&sigset, &si, &ts);
  928. Py_END_ALLOW_THREADS
  929. if (res != -1)
  930. break;
  931. if (errno != EINTR) {
  932. if (errno == EAGAIN)
  933. Py_RETURN_NONE;
  934. else
  935. return PyErr_SetFromErrno(PyExc_OSError);
  936. }
  937. /* sigtimedwait() was interrupted by a signal (EINTR) */
  938. if (PyErr_CheckSignals())
  939. return NULL;
  940. monotonic = _PyTime_GetMonotonicClock();
  941. timeout = deadline - monotonic;
  942. if (timeout < 0)
  943. break;
  944. } while (1);
  945. return fill_siginfo(&si);
  946. }
  947. #endif /* #ifdef HAVE_SIGTIMEDWAIT */
  948. #if defined(HAVE_PTHREAD_KILL)
  949. /*[clinic input]
  950. signal.pthread_kill
  951. thread_id: unsigned_long(bitwise=True)
  952. signalnum: int
  953. /
  954. Send a signal to a thread.
  955. [clinic start generated code]*/
  956. static PyObject *
  957. signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
  958. int signalnum)
  959. /*[clinic end generated code: output=7629919b791bc27f input=1d901f2c7bb544ff]*/
  960. {
  961. int err;
  962. err = pthread_kill((pthread_t)thread_id, signalnum);
  963. if (err != 0) {
  964. errno = err;
  965. PyErr_SetFromErrno(PyExc_OSError);
  966. return NULL;
  967. }
  968. /* the signal may have been send to the current thread */
  969. if (PyErr_CheckSignals())
  970. return NULL;
  971. Py_RETURN_NONE;
  972. }
  973. #endif /* #if defined(HAVE_PTHREAD_KILL) */
  974. /* List of functions defined in the module -- some of the methoddefs are
  975. defined to nothing if the corresponding C function is not available. */
  976. static PyMethodDef signal_methods[] = {
  977. {"default_int_handler", signal_default_int_handler, METH_VARARGS, default_int_handler_doc},
  978. SIGNAL_ALARM_METHODDEF
  979. SIGNAL_SETITIMER_METHODDEF
  980. SIGNAL_GETITIMER_METHODDEF
  981. SIGNAL_SIGNAL_METHODDEF
  982. SIGNAL_STRSIGNAL_METHODDEF
  983. SIGNAL_GETSIGNAL_METHODDEF
  984. {"set_wakeup_fd", (PyCFunction)(void(*)(void))signal_set_wakeup_fd, METH_VARARGS | METH_KEYWORDS, set_wakeup_fd_doc},
  985. SIGNAL_SIGINTERRUPT_METHODDEF
  986. SIGNAL_PAUSE_METHODDEF
  987. SIGNAL_PTHREAD_KILL_METHODDEF
  988. SIGNAL_PTHREAD_SIGMASK_METHODDEF
  989. SIGNAL_SIGPENDING_METHODDEF
  990. SIGNAL_SIGWAIT_METHODDEF
  991. SIGNAL_SIGWAITINFO_METHODDEF
  992. SIGNAL_SIGTIMEDWAIT_METHODDEF
  993. #if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
  994. SIGNAL_VALID_SIGNALS_METHODDEF
  995. #endif
  996. {NULL, NULL} /* sentinel */
  997. };
  998. PyDoc_STRVAR(module_doc,
  999. "This module provides mechanisms to use signal handlers in Python.\n\
  1000. \n\
  1001. Functions:\n\
  1002. \n\
  1003. alarm() -- cause SIGALRM after a specified time [Unix only]\n\
  1004. setitimer() -- cause a signal (described below) after a specified\n\
  1005. float time and the timer may restart then [Unix only]\n\
  1006. getitimer() -- get current value of timer [Unix only]\n\
  1007. signal() -- set the action for a given signal\n\
  1008. getsignal() -- get the signal action for a given signal\n\
  1009. pause() -- wait until a signal arrives [Unix only]\n\
  1010. default_int_handler() -- default SIGINT handler\n\
  1011. \n\
  1012. signal constants:\n\
  1013. SIG_DFL -- used to refer to the system default handler\n\
  1014. SIG_IGN -- used to ignore the signal\n\
  1015. NSIG -- number of defined signals\n\
  1016. SIGINT, SIGTERM, etc. -- signal numbers\n\
  1017. \n\
  1018. itimer constants:\n\
  1019. ITIMER_REAL -- decrements in real time, and delivers SIGALRM upon\n\
  1020. expiration\n\
  1021. ITIMER_VIRTUAL -- decrements only when the process is executing,\n\
  1022. and delivers SIGVTALRM upon expiration\n\
  1023. ITIMER_PROF -- decrements both when the process is executing and\n\
  1024. when the system is executing on behalf of the process.\n\
  1025. Coupled with ITIMER_VIRTUAL, this timer is usually\n\
  1026. used to profile the time spent by the application\n\
  1027. in user and kernel space. SIGPROF is delivered upon\n\
  1028. expiration.\n\
  1029. \n\n\
  1030. *** IMPORTANT NOTICE ***\n\
  1031. A signal handler function is called with two arguments:\n\
  1032. the first is the signal number, the second is the interrupted stack frame.");
  1033. static struct PyModuleDef signalmodule = {
  1034. PyModuleDef_HEAD_INIT,
  1035. "_signal",
  1036. module_doc,
  1037. -1,
  1038. signal_methods,
  1039. NULL,
  1040. NULL,
  1041. NULL,
  1042. NULL
  1043. };
  1044. PyMODINIT_FUNC
  1045. PyInit__signal(void)
  1046. {
  1047. PyObject *m, *d, *x;
  1048. int i;
  1049. main_thread = PyThread_get_thread_ident();
  1050. main_pid = getpid();
  1051. /* Create the module and add the functions */
  1052. m = PyModule_Create(&signalmodule);
  1053. if (m == NULL)
  1054. return NULL;
  1055. #if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
  1056. if (!initialized) {
  1057. if (PyStructSequence_InitType2(&SiginfoType, &struct_siginfo_desc) < 0)
  1058. return NULL;
  1059. }
  1060. Py_INCREF((PyObject*) &SiginfoType);
  1061. PyModule_AddObject(m, "struct_siginfo", (PyObject*) &SiginfoType);
  1062. initialized = 1;
  1063. #endif
  1064. /* Add some symbolic constants to the module */
  1065. d = PyModule_GetDict(m);
  1066. x = DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL);
  1067. if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0)
  1068. goto finally;
  1069. x = IgnoreHandler = PyLong_FromVoidPtr((void *)SIG_IGN);
  1070. if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0)
  1071. goto finally;
  1072. x = PyLong_FromLong((long)NSIG);
  1073. if (!x || PyDict_SetItemString(d, "NSIG", x) < 0)
  1074. goto finally;
  1075. Py_DECREF(x);
  1076. #ifdef SIG_BLOCK
  1077. if (PyModule_AddIntMacro(m, SIG_BLOCK))
  1078. goto finally;
  1079. #endif
  1080. #ifdef SIG_UNBLOCK
  1081. if (PyModule_AddIntMacro(m, SIG_UNBLOCK))
  1082. goto finally;
  1083. #endif
  1084. #ifdef SIG_SETMASK
  1085. if (PyModule_AddIntMacro(m, SIG_SETMASK))
  1086. goto finally;
  1087. #endif
  1088. x = IntHandler = PyDict_GetItemString(d, "default_int_handler");
  1089. if (!x)
  1090. goto finally;
  1091. Py_INCREF(IntHandler);
  1092. _Py_atomic_store_relaxed(&Handlers[0].tripped, 0);
  1093. for (i = 1; i < NSIG; i++) {
  1094. void (*t)(int);
  1095. t = PyOS_getsig(i);
  1096. _Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
  1097. if (t == SIG_DFL)
  1098. Handlers[i].func = DefaultHandler;
  1099. else if (t == SIG_IGN)
  1100. Handlers[i].func = IgnoreHandler;
  1101. else
  1102. Handlers[i].func = Py_None; /* None of our business */
  1103. Py_INCREF(Handlers[i].func);
  1104. }
  1105. if (Handlers[SIGINT].func == DefaultHandler) {
  1106. /* Install default int handler */
  1107. Py_INCREF(IntHandler);
  1108. Py_SETREF(Handlers[SIGINT].func, IntHandler);
  1109. PyOS_setsig(SIGINT, signal_handler);
  1110. }
  1111. #ifdef SIGHUP
  1112. if (PyModule_AddIntMacro(m, SIGHUP))
  1113. goto finally;
  1114. #endif
  1115. #ifdef SIGINT
  1116. if (PyModule_AddIntMacro(m, SIGINT))
  1117. goto finally;
  1118. #endif
  1119. #ifdef SIGBREAK
  1120. if (PyModule_AddIntMacro(m, SIGBREAK))
  1121. goto finally;
  1122. #endif
  1123. #ifdef SIGQUIT
  1124. if (PyModule_AddIntMacro(m, SIGQUIT))
  1125. goto finally;
  1126. #endif
  1127. #ifdef SIGILL
  1128. if (PyModule_AddIntMacro(m, SIGILL))
  1129. goto finally;
  1130. #endif
  1131. #ifdef SIGTRAP
  1132. if (PyModule_AddIntMacro(m, SIGTRAP))
  1133. goto finally;
  1134. #endif
  1135. #ifdef SIGIOT
  1136. if (PyModule_AddIntMacro(m, SIGIOT))
  1137. goto finally;
  1138. #endif
  1139. #ifdef SIGABRT
  1140. if (PyModule_AddIntMacro(m, SIGABRT))
  1141. goto finally;
  1142. #endif
  1143. #ifdef SIGEMT
  1144. if (PyModule_AddIntMacro(m, SIGEMT))
  1145. goto finally;
  1146. #endif
  1147. #ifdef SIGFPE
  1148. if (PyModule_AddIntMacro(m, SIGFPE))
  1149. goto finally;
  1150. #endif
  1151. #ifdef SIGKILL
  1152. if (PyModule_AddIntMacro(m, SIGKILL))
  1153. goto finally;
  1154. #endif
  1155. #ifdef SIGBUS
  1156. if (PyModule_AddIntMacro(m, SIGBUS))
  1157. goto finally;
  1158. #endif
  1159. #ifdef SIGSEGV
  1160. if (PyModule_AddIntMacro(m, SIGSEGV))
  1161. goto finally;
  1162. #endif
  1163. #ifdef SIGSYS
  1164. if (PyModule_AddIntMacro(m, SIGSYS))
  1165. goto finally;
  1166. #endif
  1167. #ifdef SIGPIPE
  1168. if (PyModule_AddIntMacro(m, SIGPIPE))
  1169. goto finally;
  1170. #endif
  1171. #ifdef SIGALRM
  1172. if (PyModule_AddIntMacro(m, SIGALRM))
  1173. goto finally;
  1174. #endif
  1175. #ifdef SIGTERM
  1176. if (PyModule_AddIntMacro(m, SIGTERM))
  1177. goto finally;
  1178. #endif
  1179. #ifdef SIGUSR1
  1180. if (PyModule_AddIntMacro(m, SIGUSR1))
  1181. goto finally;
  1182. #endif
  1183. #ifdef SIGUSR2
  1184. if (PyModule_AddIntMacro(m, SIGUSR2))
  1185. goto finally;
  1186. #endif
  1187. #ifdef SIGCLD
  1188. if (PyModule_AddIntMacro(m, SIGCLD))
  1189. goto finally;
  1190. #endif
  1191. #ifdef SIGCHLD
  1192. if (PyModule_AddIntMacro(m, SIGCHLD))
  1193. goto finally;
  1194. #endif
  1195. #ifdef SIGPWR
  1196. if (PyModule_AddIntMacro(m, SIGPWR))
  1197. goto finally;
  1198. #endif
  1199. #ifdef SIGIO
  1200. if (PyModule_AddIntMacro(m, SIGIO))
  1201. goto finally;
  1202. #endif
  1203. #ifdef SIGURG
  1204. if (PyModule_AddIntMacro(m, SIGURG))
  1205. goto finally;
  1206. #endif
  1207. #ifdef SIGWINCH
  1208. if (PyModule_AddIntMacro(m, SIGWINCH))
  1209. goto finally;
  1210. #endif
  1211. #ifdef SIGPOLL
  1212. if (PyModule_AddIntMacro(m, SIGPOLL))
  1213. goto finally;
  1214. #endif
  1215. #ifdef SIGSTOP
  1216. if (PyModule_AddIntMacro(m, SIGSTOP))
  1217. goto finally;
  1218. #endif
  1219. #ifdef SIGTSTP
  1220. if (PyModule_AddIntMacro(m, SIGTSTP))
  1221. goto finally;
  1222. #endif
  1223. #ifdef SIGCONT
  1224. if (PyModule_AddIntMacro(m, SIGCONT))
  1225. goto finally;
  1226. #endif
  1227. #ifdef SIGTTIN
  1228. if (PyModule_AddIntMacro(m, SIGTTIN))
  1229. goto finally;
  1230. #endif
  1231. #ifdef SIGTTOU
  1232. if (PyModule_AddIntMacro(m, SIGTTOU))
  1233. goto finally;
  1234. #endif
  1235. #ifdef SIGVTALRM
  1236. if (PyModule_AddIntMacro(m, SIGVTALRM))
  1237. goto finally;
  1238. #endif
  1239. #ifdef SIGPROF
  1240. if (PyModule_AddIntMacro(m, SIGPROF))
  1241. goto finally;
  1242. #endif
  1243. #ifdef SIGXCPU
  1244. if (PyModule_AddIntMacro(m, SIGXCPU))
  1245. goto finally;
  1246. #endif
  1247. #ifdef SIGXFSZ
  1248. if (PyModule_AddIntMacro(m, SIGXFSZ))
  1249. goto finally;
  1250. #endif
  1251. #ifdef SIGRTMIN
  1252. if (PyModule_AddIntMacro(m, SIGRTMIN))
  1253. goto finally;
  1254. #endif
  1255. #ifdef SIGRTMAX
  1256. if (PyModule_AddIntMacro(m, SIGRTMAX))
  1257. goto finally;
  1258. #endif
  1259. #ifdef SIGINFO
  1260. if (PyModule_AddIntMacro(m, SIGINFO))
  1261. goto finally;
  1262. #endif
  1263. #ifdef ITIMER_REAL
  1264. if (PyModule_AddIntMacro(m, ITIMER_REAL))
  1265. goto finally;
  1266. #endif
  1267. #ifdef ITIMER_VIRTUAL
  1268. if (PyModule_AddIntMacro(m, ITIMER_VIRTUAL))
  1269. goto finally;
  1270. #endif
  1271. #ifdef ITIMER_PROF
  1272. if (PyModule_AddIntMacro(m, ITIMER_PROF))
  1273. goto finally;
  1274. #endif
  1275. #if defined (HAVE_SETITIMER) || defined (HAVE_GETITIMER)
  1276. ItimerError = PyErr_NewException("signal.ItimerError",
  1277. PyExc_OSError, NULL);
  1278. if (ItimerError != NULL)
  1279. PyDict_SetItemString(d, "ItimerError", ItimerError);
  1280. #endif
  1281. #ifdef CTRL_C_EVENT
  1282. if (PyModule_AddIntMacro(m, CTRL_C_EVENT))
  1283. goto finally;
  1284. #endif
  1285. #ifdef CTRL_BREAK_EVENT
  1286. if (PyModule_AddIntMacro(m, CTRL_BREAK_EVENT))
  1287. goto finally;
  1288. #endif
  1289. #ifdef MS_WINDOWS
  1290. /* Create manual-reset event, initially unset */
  1291. sigint_event = CreateEvent(NULL, TRUE, FALSE, FALSE);
  1292. #endif
  1293. if (PyErr_Occurred()) {
  1294. Py_DECREF(m);
  1295. m = NULL;
  1296. }
  1297. finally:
  1298. return m;
  1299. }
  1300. static void
  1301. finisignal(void)
  1302. {
  1303. int i;
  1304. PyObject *func;
  1305. for (i = 1; i < NSIG; i++) {
  1306. func = Handlers[i].func;
  1307. _Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
  1308. Handlers[i].func = NULL;
  1309. if (func != NULL && func != Py_None &&
  1310. func != DefaultHandler && func != IgnoreHandler)
  1311. PyOS_setsig(i, SIG_DFL);
  1312. Py_XDECREF(func);
  1313. }
  1314. Py_CLEAR(IntHandler);
  1315. Py_CLEAR(DefaultHandler);
  1316. Py_CLEAR(IgnoreHandler);
  1317. }
  1318. /* Declared in pyerrors.h */
  1319. int
  1320. PyErr_CheckSignals(void)
  1321. {
  1322. int i;
  1323. PyObject *f;
  1324. if (!_Py_atomic_load(&is_tripped))
  1325. return 0;
  1326. if (PyThread_get_thread_ident() != main_thread)
  1327. return 0;
  1328. /*
  1329. * The is_tripped variable is meant to speed up the calls to
  1330. * PyErr_CheckSignals (both directly or via pending calls) when no
  1331. * signal has arrived. This variable is set to 1 when a signal arrives
  1332. * and it is set to 0 here, when we know some signals arrived. This way
  1333. * we can run the registered handlers with no signals blocked.
  1334. *
  1335. * NOTE: with this approach we can have a situation where is_tripped is
  1336. * 1 but we have no more signals to handle (Handlers[i].tripped
  1337. * is 0 for every signal i). This won't do us any harm (except
  1338. * we're gonna spent some cycles for nothing). This happens when
  1339. * we receive a signal i after we zero is_tripped and before we
  1340. * check Handlers[i].tripped.
  1341. */
  1342. _Py_atomic_store(&is_tripped, 0);
  1343. if (!(f = (PyObject *)PyEval_GetFrame()))
  1344. f = Py_None;
  1345. for (i = 1; i < NSIG; i++) {
  1346. if (_Py_atomic_load_relaxed(&Handlers[i].tripped)) {
  1347. PyObject *result = NULL;
  1348. PyObject *arglist = Py_BuildValue("(iO)", i, f);
  1349. _Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
  1350. if (arglist) {
  1351. result = PyEval_CallObject(Handlers[i].func,
  1352. arglist);
  1353. Py_DECREF(arglist);
  1354. }
  1355. if (!result) {
  1356. _Py_atomic_store(&is_tripped, 1);
  1357. return -1;
  1358. }
  1359. Py_DECREF(result);
  1360. }
  1361. }
  1362. return 0;
  1363. }
  1364. /* Replacements for intrcheck.c functionality
  1365. * Declared in pyerrors.h
  1366. */
  1367. void
  1368. PyErr_SetInterrupt(void)
  1369. {
  1370. trip_signal(SIGINT);
  1371. }
  1372. void
  1373. PyOS_InitInterrupts(void)
  1374. {
  1375. PyObject *m = PyImport_ImportModule("_signal");
  1376. if (m) {
  1377. Py_DECREF(m);
  1378. }
  1379. }
  1380. void
  1381. PyOS_FiniInterrupts(void)
  1382. {
  1383. finisignal();
  1384. }
  1385. int
  1386. PyOS_InterruptOccurred(void)
  1387. {
  1388. if (_Py_atomic_load_relaxed(&Handlers[SIGINT].tripped)) {
  1389. if (PyThread_get_thread_ident() != main_thread)
  1390. return 0;
  1391. _Py_atomic_store_relaxed(&Handlers[SIGINT].tripped, 0);
  1392. return 1;
  1393. }
  1394. return 0;
  1395. }
  1396. static void
  1397. _clear_pending_signals(void)
  1398. {
  1399. int i;
  1400. if (!_Py_atomic_load(&is_tripped))
  1401. return;
  1402. _Py_atomic_store(&is_tripped, 0);
  1403. for (i = 1; i < NSIG; ++i) {
  1404. _Py_atomic_store_relaxed(&Handlers[i].tripped, 0);
  1405. }
  1406. }
  1407. void
  1408. _PySignal_AfterFork(void)
  1409. {
  1410. /* Clear the signal flags after forking so that they aren't handled
  1411. * in both processes if they came in just before the fork() but before
  1412. * the interpreter had an opportunity to call the handlers. issue9535. */
  1413. _clear_pending_signals();
  1414. main_thread = PyThread_get_thread_ident();
  1415. main_pid = getpid();
  1416. }
  1417. int
  1418. _PyOS_IsMainThread(void)
  1419. {
  1420. return PyThread_get_thread_ident() == main_thread;
  1421. }
  1422. #ifdef MS_WINDOWS
  1423. void *_PyOS_SigintEvent(void)
  1424. {
  1425. /* Returns a manual-reset event which gets tripped whenever
  1426. SIGINT is received.
  1427. Python.h does not include windows.h so we do cannot use HANDLE
  1428. as the return type of this function. We use void* instead. */
  1429. return sigint_event;
  1430. }
  1431. #endif