From 451b7e980ef00a10e8adfcd43273ceb7db971543 Mon Sep 17 00:00:00 2001 From: Bert JW Regeer Date: Mon, 17 Jan 2022 00:01:29 -0700 Subject: Bugfix on Windows: OSError is not subscriptable When Waitress fails to launch on Windows due to an issue with the trigger socket not being ready for connections, we attempt to loop. In the past this was done by subscripting the OSError and checking to see if it matched errno.WSAEADDRINUSE, this is no longer possible in newer verisons of Python. This is a quick bugfix for a rare case which should no longer happen on Windows. --- src/waitress/trigger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/waitress/trigger.py b/src/waitress/trigger.py index 3b1ad46..49b2034 100644 --- a/src/waitress/trigger.py +++ b/src/waitress/trigger.py @@ -173,7 +173,7 @@ else: # pragma: no cover w.connect(connect_address) break # success except OSError as detail: - if detail[0] != errno.WSAEADDRINUSE: + if getattr(detail, "winerror", None) != errno.WSAEADDRINUSE: # "Address already in use" is the only error # I've seen on two WinXP Pro SP2 boxes, under # Pythons 2.3.5 and 2.4.1. -- cgit v1.2.1