cpython: d500d1a9615f (original) (raw)

Mercurial > cpython

changeset 100285:d500d1a9615f

Issue #23430: Stop socketserver from catching SystemExit etc from handlers Also make handle_error() consistently output to stderr, and fix the documentation. [#23430]

Martin Panter vadmium+py@gmail.com
date Sun, 21 Feb 2016 08:49:56 +0000
parents 2d746fb08d0d
children f555ef42ad62
files Doc/library/socketserver.rst Doc/whatsnew/3.6.rst Lib/socketserver.py Lib/test/test_socketserver.py Misc/NEWS
diffstat 5 files changed, 131 insertions(+), 15 deletions(-)[+] [-] Doc/library/socketserver.rst 6 Doc/whatsnew/3.6.rst 11 Lib/socketserver.py 31 Lib/test/test_socketserver.py 92 Misc/NEWS 6

line wrap: on

line diff

--- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -304,7 +304,11 @@ Server Objects This function is called if the :meth:~BaseRequestHandler.handle method of a :attr:RequestHandlerClass instance raises an exception. The default action is to print the traceback to

+

.. method:: handle_timeout()

--- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -334,7 +334,16 @@ Changes in the Python API

--- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -132,6 +132,7 @@ import socket import selectors import os import errno +import sys try: import threading except ImportError: @@ -316,9 +317,12 @@ class BaseServer: if self.verify_request(request, client_address): try: self.process_request(request, client_address)

@@ -372,12 +376,12 @@ class BaseServer: The default is to print a traceback and continue. """

class TCPServer(BaseServer): @@ -601,16 +605,17 @@ class ForkingMixIn: else: # Child process. # This must never return, hence os._exit()

class ThreadingMixIn: @@ -628,9 +633,9 @@ class ThreadingMixIn: """ try: self.finish_request(request, client_address)

def process_request(self, request, client_address):

--- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -58,6 +58,7 @@ if HAVE_UNIX_SOCKETS: @contextlib.contextmanager def simple_subprocess(testcase):

@@ -281,6 +282,97 @@ class SocketServerTest(unittest.TestCase socketserver.StreamRequestHandler) +class ErrorHandlerTest(unittest.TestCase):

+

+

+

+

+

+

+

+

+ + +class BaseErrorTestServer(socketserver.TCPServer):

+

+

+ + +class BadHandler(socketserver.BaseRequestHandler):

+ + +class ThreadingErrorTestServer(socketserver.ThreadingMixIn,

+

+

+ + +class ForkingErrorTestServer(socketserver.ForkingMixIn, BaseErrorTestServer):

+ + class MiscTestCase(unittest.TestCase): def test_all(self):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -196,6 +196,12 @@ Issue #26186: Remove an invalid type che the connected socket) when verify_request() returns false. Patch by Aviv Palivoda. +- Issue #23430: Change the socketserver module to only catch exceptions