New submission from Sergey M. <seregaxvm.m...@gmail.com>:
Due to ```python try: self.handle() finally: self.finish() ``` construct in `socketserver.BaseRequestHandler.__init__()` method inherited classes with `overrided __init__()` method may suffer from incomplete initialization. For example, in the following snippet ```python def __init__(self, request, client_address, server): super().__init__(request, client_address, server) self.foo = 1 ``` in some cases all the code after `super()` call will not be executed. This is a MWE of the server with partially initialized Handler class ```python from socketserver import UnixStreamServer, StreamRequestHandler, ForkingMixIn class Handler(StreamRequestHandler): def __init__(self, request, client_address, server): super().__init__(request, client_address, server) self.foo = 1 def handle(self): print(self.foo) class ThreadedUnixStreamServer(ForkingMixIn, UnixStreamServer): pass with ThreadedUnixStreamServer("/tmp/test.socket", Handler) as server: server.serve_forever() ``` ---------- components: Library (Lib) messages: 406413 nosy: matsievskiysv priority: normal severity: normal status: open title: socketserver.BaseRequestHandler inherited class type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45818> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com