diff --git a/00271-asyncio-get-default-signal-handler.patch b/00271-asyncio-get-default-signal-handler.patch new file mode 100644 index 0000000..8b1bf77 --- /dev/null +++ b/00271-asyncio-get-default-signal-handler.patch @@ -0,0 +1,99 @@ +diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py +index 492a84a2313..9746678607c 100644 +--- a/Lib/test/test_asyncio/test_events.py ++++ b/Lib/test/test_asyncio/test_events.py +@@ -1980,19 +1980,26 @@ def test_subprocess_terminate(self): + + @unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP") + def test_subprocess_send_signal(self): +- prog = os.path.join(os.path.dirname(__file__), 'echo.py') +- +- connect = self.loop.subprocess_exec( +- functools.partial(MySubprocessProtocol, self.loop), +- sys.executable, prog) +- transp, proto = self.loop.run_until_complete(connect) +- self.assertIsInstance(proto, MySubprocessProtocol) +- self.loop.run_until_complete(proto.connected) +- +- transp.send_signal(signal.SIGHUP) +- self.loop.run_until_complete(proto.completed) +- self.assertEqual(-signal.SIGHUP, proto.returncode) +- transp.close() ++ # bpo-31034: Make sure that we get the default signal handler (killing ++ # the process). The parent process may have decided to ignore SIGHUP, ++ # and signal handlers are inherited. ++ old_handler = signal.signal(signal.SIGHUP, signal.SIG_DFL) ++ try: ++ prog = os.path.join(os.path.dirname(__file__), 'echo.py') ++ ++ connect = self.loop.subprocess_exec( ++ functools.partial(MySubprocessProtocol, self.loop), ++ sys.executable, prog) ++ transp, proto = self.loop.run_until_complete(connect) ++ self.assertIsInstance(proto, MySubprocessProtocol) ++ self.loop.run_until_complete(proto.connected) ++ ++ transp.send_signal(signal.SIGHUP) ++ self.loop.run_until_complete(proto.completed) ++ self.assertEqual(-signal.SIGHUP, proto.returncode) ++ transp.close() ++ finally: ++ signal.signal(signal.SIGHUP, old_handler) + + def test_subprocess_stderr(self): + prog = os.path.join(os.path.dirname(__file__), 'echo2.py') +diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py +index 2e14a8a9735..e8822c36698 100644 +--- a/Lib/test/test_asyncio/test_subprocess.py ++++ b/Lib/test/test_asyncio/test_subprocess.py +@@ -166,25 +166,32 @@ def test_terminate(self): + + @unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP") + def test_send_signal(self): +- code = 'import time; print("sleeping", flush=True); time.sleep(3600)' +- args = [sys.executable, '-c', code] +- create = asyncio.create_subprocess_exec(*args, +- stdout=subprocess.PIPE, +- loop=self.loop) +- proc = self.loop.run_until_complete(create) +- +- @asyncio.coroutine +- def send_signal(proc): +- # basic synchronization to wait until the program is sleeping +- line = yield from proc.stdout.readline() +- self.assertEqual(line, b'sleeping\n') ++ # bpo-31034: Make sure that we get the default signal handler (killing ++ # the process). The parent process may have decided to ignore SIGHUP, ++ # and signal handlers are inherited. ++ old_handler = signal.signal(signal.SIGHUP, signal.SIG_DFL) ++ try: ++ code = 'import time; print("sleeping", flush=True); time.sleep(3600)' ++ args = [sys.executable, '-c', code] ++ create = asyncio.create_subprocess_exec(*args, ++ stdout=subprocess.PIPE, ++ loop=self.loop) ++ proc = self.loop.run_until_complete(create) + +- proc.send_signal(signal.SIGHUP) +- returncode = (yield from proc.wait()) +- return returncode +- +- returncode = self.loop.run_until_complete(send_signal(proc)) +- self.assertEqual(-signal.SIGHUP, returncode) ++ @asyncio.coroutine ++ def send_signal(proc): ++ # basic synchronization to wait until the program is sleeping ++ line = yield from proc.stdout.readline() ++ self.assertEqual(line, b'sleeping\n') ++ ++ proc.send_signal(signal.SIGHUP) ++ returncode = (yield from proc.wait()) ++ return returncode ++ ++ returncode = self.loop.run_until_complete(send_signal(proc)) ++ self.assertEqual(-signal.SIGHUP, returncode) ++ finally: ++ signal.signal(signal.SIGHUP, old_handler) + + def prepare_broken_pipe_test(self): + # buffer large enough to feed the whole pipe buffer diff --git a/python3.spec b/python3.spec index 6256430..97ad114 100644 --- a/python3.spec +++ b/python3.spec @@ -123,7 +123,7 @@ Summary: Version 3 of the Python programming language aka Python 3000 Name: python3 Version: %{pybasever}.2 -Release: 1%{?dist} +Release: 2%{?dist} License: Python Group: Development/Languages @@ -427,6 +427,12 @@ Patch264: 00264-skip-test-failing-on-aarch64.patch # Fixed upstream: http://bugs.python.org/issue30714 Patch270: 00270-fix-ssl-alpn-hook-test.patch +# 00271 # +# Make test_asyncio to not depend on the current signal handler +# as this can make it hang on koji, since it ignores SIGHUP. +# Reported upstream: http://bugs.python.org/issue31034 +Patch271: 00271-asyncio-get-default-signal-handler.patch + # (New patches go here ^^^) # # When adding new patches to "python" and "python3" in Fedora, EL, etc., @@ -698,6 +704,7 @@ sed -r -i s/'_PIP_VERSION = "[0-9.]+"'/'_PIP_VERSION = "%{pip_version}"'/ Lib/en %endif %patch270 -p1 +%patch271 -p1 # Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there # are many differences between 2.6 and the Python 3 library. @@ -1658,6 +1665,9 @@ fi # ====================================================== %changelog +* Tue Jul 25 2017 Charalampos Stratakis - 3.6.2-2 +- Make test_asyncio to not depend on the current SIGHUP signal handler. + * Tue Jul 18 2017 Charalampos Stratakis - 3.6.2-1 - Update to Python 3.6.2