summaryrefslogtreecommitdiff
path: root/Lib/test/test_signal.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.10] bpo-44559: [Enum] revert enum module to 3.9 (GH-27010)Ethan Furman2021-07-031-28/+1
| | | * [Enum] revert enum module to 3.9
* bpo-43957: [Enum] Deprecate ``TypeError`` from containment checks. (GH-25670)Ethan Furman2021-04-271-1/+1
| | | | | In 3.12 ``True`` or ``False`` will be returned for all containment checks, with ``True`` being returned if the value is either a member of that enum or one of its members' value.
* bpo-38659: [Enum] add _simple_enum decorator (GH-25497)Ethan Furman2021-04-211-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add: * `_simple_enum` decorator to transform a normal class into an enum * `_test_simple_enum` function to compare * `_old_convert_` to enable checking `_convert_` generated enums `_simple_enum` takes a normal class and converts it into an enum: @simple_enum(Enum) class Color: RED = 1 GREEN = 2 BLUE = 3 `_old_convert_` works much like` _convert_` does, using the original logic: # in a test file import socket, enum CheckedAddressFamily = enum._old_convert_( enum.IntEnum, 'AddressFamily', 'socket', lambda C: C.isupper() and C.startswith('AF_'), source=_socket, ) `_test_simple_enum` takes a traditional enum and a simple enum and compares the two: # in the REPL or the same module as Color class CheckedColor(Enum): RED = 1 GREEN = 2 BLUE = 3 _test_simple_enum(CheckedColor, Color) _test_simple_enum(CheckedAddressFamily, socket.AddressFamily) Any important differences will raise a TypeError
* Revert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)Ethan Furman2021-04-191-27/+0
| | | This reverts commit dbac8f40e81eb0a29dc833e6409a1abf47467da6.
* bpo-38659: [Enum] add _simple_enum decorator (GH-25285)Ethan Furman2021-04-191-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add: _simple_enum decorator to transform a normal class into an enum _test_simple_enum function to compare _old_convert_ to enable checking _convert_ generated enums _simple_enum takes a normal class and converts it into an enum: @simple_enum(Enum) class Color: RED = 1 GREEN = 2 BLUE = 3 _old_convert_ works much like _convert_ does, using the original logic: # in a test file import socket, enum CheckedAddressFamily = enum._old_convert_( enum.IntEnum, 'AddressFamily', 'socket', lambda C: C.isupper() and C.startswith('AF_'), source=_socket, ) test_simple_enum takes a traditional enum and a simple enum and compares the two: # in the REPL or the same module as Color class CheckedColor(Enum): RED = 1 GREEN = 2 BLUE = 3 _test_simple_enum(CheckedColor, Color) _test_simple_enum(CheckedAddressFamily, socket.AddressFamily) Any important differences will raise a TypeError
* bpo-40066: Enum: modify `repr()` and `str()` (GH-22392)Ethan Furman2021-03-301-1/+1
| | | | | | | | | * Enum: streamline repr() and str(); improve docs - repr() is now ``enum_class.member_name`` - stdlib global enums are ``module_name.member_name`` - str() is now ``member_name`` - add HOW-TO section for ``Enum`` - change main documentation to be an API reference
* bpo-43406: Fix test_signal.test_stress_modifying_handlers() (GH-24815)Victor Stinner2021-03-101-3/+13
| | | | | | | Fix a race condition of test_stress_modifying_handlers() of test_signal: only raise signals while we are in the catch_unraisable_exception() context manager. Moreover, don't check if we received at least one signal if at least one signal got ignored.
* bpo-43406: Fix possible race condition where ``PyErr_CheckSignals`` tries to ↵Antoine Pitrou2021-03-051-0/+50
| | | | | | execute a non-Python signal handler (GH-24756) We can receive signals (at the C level, in `trip_signal()` in signalmodule.c) while `signal.signal` is being called to modify the corresponding handler. Later when `PyErr_CheckSignals()` is called to handle the given signal, the handler may be a non-callable object and would raise a cryptic asynchronous exception.
* bpo-31904: Support signal module on VxWorks (GH-23391)pxinwr2020-11-301-3/+10
|
* bpo-42413: socket.timeout is now an alias of TimeoutError (GH-23413)Christian Heimes2020-11-201-1/+1
| | | Signed-off-by: Christian Heimes <christian@python.org>
* bpo-40275: Use new test.support helper submodules in tests (GH-21449)Hai Shi2020-08-031-1/+2
|
* bpo-39424: Use assertRaisesRegex instead of assertRaisesRegexp. (GH-18277)damani422020-01-301-1/+1
|
* bpo-39157: Skip test_pidfd_send_signal if the system does not have enough ↵Pablo Galindo2019-12-291-0/+2
| | | | privileges to use pidfd (GH-17740)
* bpo-38614: Use test.support.SHORT_TIMEOUT constant (GH-17566)Victor Stinner2019-12-111-3/+3
| | | | | | | | | | | | | | | Replace hardcoded timeout constants in tests with SHORT_TIMEOUT of test.support, so it's easier to ajdust this timeout for all tests at once. SHORT_TIMEOUT is 30 seconds by default, but it can be longer depending on --timeout command line option. The change makes almost all timeouts longer, except test_reap_children() of test_support which is made 2x shorter: SHORT_TIMEOUT should be enough. If this test starts to fail, LONG_TIMEOUT should be used instead. Uniformize also "from test import support" import in some test files.
* closes bpo-38712: Add signal.pidfd_send_signal. (GH-17070)Benjamin Peterson2019-11-191-0/+19
| | | | | | | | This exposes a Linux-specific syscall for sending a signal to a process identified by a file descriptor rather than a pid. For simplicity, we don't support the siginfo_t parameter to the syscall. This parameter allows implementing a pidfd version of rt_sigqueueinfo(2), which Python also doesn't support.
* Remove unused imports in tests (GH-14518)Victor Stinner2019-07-011-1/+0
|
* bpo-36013: delete fragile interactive shell SIGINT test (GH-11902)Gregory P. Smith2019-02-161-33/+7
| | | | | It makes the existing smaller test more readable and robust at the same time. The execution of a shell in interactive mode from CI and buildbot test automation wasn't working out. What would work locally in our terminals would only work within a fraction of automation systems. The integration test was a nice to have. painful. deleting. :)
* bpo-1054041: Exit properly after an uncaught ^C. (#11862)Gregory P. Smith2019-02-161-4/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-1054041: Exit properly by a signal after a ^C. An uncaught KeyboardInterrupt exception means the user pressed ^C and our code did not handle it. Programs that install SIGINT handlers are supposed to reraise the SIGINT signal to the SIG_DFL handler in order to exit in a manner that their calling process can detect that they died due to a Ctrl-C. https://www.cons.org/cracauer/sigint.html After this change on POSIX systems while true; do python -c 'import time; time.sleep(23)'; done can be stopped via a simple Ctrl-C instead of the shell infinitely restarting a new python process. What to do on Windows, or if anything needs to be done there has not yet been determined. That belongs in its own PR. TODO(gpshead): A unittest for this behavior is still needed. * Do the unhandled ^C check after pymain_free. * Return STATUS_CONTROL_C_EXIT on Windows. * Fix ifdef around unistd.h include. * 📜🤖 Added by blurb_it. * Add STATUS_CTRL_C_EXIT to the os module on Windows * Add unittests. * Don't send CTRL_C_EVENT in the Windows test. It was causing CI systems to bail out of the entire test suite. See https://dev.azure.com/Python/cpython/_build/results?buildId=37980 for example. * Correct posix test (fail on macOS?) check. * STATUS_CONTROL_C_EXIT must be unsigned. * Improve the error message. * test typo :) * Skip if the bash version is too old. ...and rename the windows test to reflect what it does. * min bash version is 4.4, detect no bash. * restore a blank line i didn't mean to delete. * PyErr_Occurred() before the Py_DECREF(co); * Don't add os.STATUS_CONTROL_C_EXIT as a constant. * Update the Windows test comment. * Refactor common logic into a run_eval_code_obj fn.
* bpo-35568: add 'raise_signal' function (GH-11335)Vladimir Matveev2019-01-081-12/+44
| | | | | | As in title, expose C `raise` function as `raise_function` in `signal` module. Also drop existing `raise_signal` in `_testcapi` module and replace all usages with new function. https://bugs.python.org/issue35568
* bpo-35513: Replace time.time() with time.monotonic() in tests (GH-11182)Victor Stinner2018-12-171-5/+5
| | | | | | | Replace time.time() with time.monotonic() in tests to measure time delta. test_zipfile64: display progress every minute (60 secs) rather than every 5 minutes (5*60 seconds).
* bpo-34412: Make signal.strsignal() work on HP-UX (GH-8786)Michael Osipov2018-08-231-0/+1
| | | | | | Introduce a configure check for strsignal(3) which defines HAVE_STRSIGNAL for signalmodule.c. Add some common signals on HP-UX. This change applies for Windows and HP-UX.
* bpo-34130: Fix test_signal.test_warn_on_full_buffer() (GH-8327)Victor Stinner2018-07-181-15/+41
| | | | | | | | | | | | | | | | | On Windows, sometimes test_signal.test_warn_on_full_buffer() fails to fill the socketpair buffer. In that case, the C signal handler succeed to write into the socket, it doesn't log the expected send error, and so the test fail. On Windows, the test now uses a timeout of 50 ms to fill the socketpair buffer to fix this race condition. Other changes: * Begin with large chunk size to fill the buffer to speed up the test. * Add error messages to assertion errors to more easily identify which assertion failed. * Don't set the read end of the socketpair as non-blocking.
* bpo-34130: Fix test_signal.test_socket() (GH-8326)Victor Stinner2018-07-181-1/+0
| | | | | | | | test_signal.test_socket(): On Windows, sometimes even if the C signal handler succeed to write the signal number into the write end of the socketpair, the test fails with a BlockingIOError on the non-blocking read.recv(1) because the read end of the socketpair didn't receive the byte yet. Fix the race condition on Windows by setting the read end as blocking.
* bpo-33441: Make the sigset_t converter available in other modules. (GH-6720)Serhiy Storchaka2018-05-081-0/+4
| | | | | | | | | * Expose the sigset_t converter via private API _Py_Sigset_Converter(). * Use Argument Clinic for parsing sigset_t in signalmodule.c. * Raise ValueError instead OverflowError for integers out of the C long range. Based on patch by Pablo Galindo Salgado.
* bpo-33332: Add signal.valid_signals() (GH-6581)Antoine Pitrou2018-05-041-0/+30
|
* bpo-22674: fix test_strsignal on OSX (GH-6085)Antoine Pietri2018-03-121-2/+2
|
* signal: add strsignal() (#6017)Antoine Pietri2018-03-121-0/+6
| | | Co-authored-by: Vajrasky Kok <sky.kok@speaklikeaking.com>
* bpo-32593: Drop FreeBSD 9 and older support (#5232)Victor Stinner2018-01-221-20/+1
| | | Drop support of FreeBSD 9 and older.
* bpo-30050: Allow disabling full buffer warnings in signal.set_wakeup_fd (#4792)Nathaniel J. Smith2017-12-171-0/+92
|
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-6/+1
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-30807: signal.setitimer() may disable the timer by mistake (#2493)Antoine Pitrou2017-06-301-0/+9
| | | | | | * bpo-30807: signal.setitimer() may disable the timer by mistake * Add NEWS blurb
* bpo-30796: Fix failures in signal delivery stress test (#2488)Antoine Pitrou2017-06-291-15/+50
| | | | | | | | | | * bpo-30796: Fix failures in signal delivery stress test setitimer() can have a poor minimum resolution on some machines, this would make the test reach its deadline (and a stray signal could then kill a subsequent test). * Make sure to clear the itimer after the test
* bpo-30703: Improve signal delivery (#2415)Antoine Pitrou2017-06-281-0/+96
| | | | | | | | | | | | | | | | | | | | * Improve signal delivery Avoid using Py_AddPendingCall from signal handler, to avoid calling signal-unsafe functions. * Remove unused function * Improve comments * Add stress test * Adapt for --without-threads * Add second stress test * Add NEWS blurb * Address comments @haypo
* bpo-29919: Remove unused imports found by pyflakes (#137)Victor Stinner2017-03-271-6/+5
| | | Make also minor PEP8 coding style fixes on modified imports.
* Remove unused imports.Serhiy Storchaka2016-12-161-4/+0
|
* Issue #26566: Rewrite test_signal.InterProcessSignalTestsVictor Stinner2016-03-151-162/+9
| | | | | | | | | | | | | | * Add Lib/test/signalinterproctester.py * Don't disable the garbage collector anymore * Don't use os.fork() with a subprocess to not inherit existing signal handlers or threads: start from a fresh process * Don't use UNIX kill command to send a signal but Python os.kill() * Use a timeout of 10 seconds to wait for the signal instead of 1 second * Always use signal.pause(), instead of time.wait(1), to wait for a signal * Use context manager on subprocess.Popen * remove code to retry on EINTR: it's no more needed since the PEP 475 * remove unused function exit_subprocess() * Cleanup the code
* Issue #9517: Move script_helper to the support package.Berker Peksag2015-05-061-1/+1
| | | | Patch by Christie Wilson.
* Issue #21741: Update 147 test modules to use test discovery.Zachary Ware2015-04-131-11/+3
| | | | | | | I have compared output between pre- and post-patch runs of these tests to make sure there's nothing missing and nothing broken, on both Windows and Linux. The only differences I found were actually tests that were previously *not* run.
* Issue #23485: Fix test_signal, select.select() now retries the syscall if theVictor Stinner2015-03-301-3/+17
| | | | signal handler does not raise an exception
* Issue #23715: signal.sigwaitinfo() and signal.sigtimedwait() are now retriedVictor Stinner2015-03-201-29/+0
| | | | | | | | | | when interrupted by a signal not in the *sigset* parameter, if the signal handler does not raise an exception. signal.sigtimedwait() recomputes the timeout with a monotonic clock when it is retried. Remove test_signal.test_sigwaitinfo_interrupted() because sigwaitinfo() doesn't raise InterruptedError anymore if it is interrupted by a signal not in its sigset parameter.
* Issue #23646: If time.sleep() is interrupted by a signal, the sleep is nowVictor Stinner2015-03-191-14/+17
| | | | | | | retried with the recomputed delay, except if the signal handler raises an exception (PEP 475). Modify also test_signal to use a monotonic clock instead of the system clock.
* Revert changeset d927047b1d8eb87738676980a24930d053ba2150Victor Stinner2015-03-171-10/+7
| | | | Sorry, it was a mistake, the patch is still under review: issue #23646.
* testVictor Stinner2015-03-121-7/+10
|
* Issue #23285: PEP 475 -- Retry system calls failing with EINTR.Charles-François Natali2015-02-071-4/+3
|
* Issue #22042: Fix test_signal on WindowsVictor Stinner2014-08-271-2/+3
|
* Issue #22042: signal.set_wakeup_fd(fd) now raises an exception if the fileVictor Stinner2014-08-271-0/+25
| | | | descriptor is in blocking mode.
* Issue #22018: Fix test_signal: use assertEqual() not assertIs()Victor Stinner2014-07-301-3/+3
|
* Issue #22018: On Windows, signal.set_wakeup_fd() now also supports sockets.Victor Stinner2014-07-291-0/+107
| | | | A side effect is that Python depends to the WinSock library.
* Issue #22054: Add os.get_blocking() and os.set_blocking() functions to get andVictor Stinner2014-07-291-8/+2
| | | | | set the blocking mode of a file descriptor (False if the O_NONBLOCK flag is set, True otherwise). These functions are not available on Windows.
* Issue #22018: Fix test_set_wakeup_fd_result(), use assertEqual() notVictor Stinner2014-07-241-3/+3
| | | | assertIs().