File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,13 +205,22 @@ def _on_timeout():
205205 self .redirect_port = port
206206 break
207207 except OSError as e :
208+ # Record every bind-time OSError so the fall-through
209+ # `raise last_error` below always re-raises a real exception.
210+ # If we only recorded the port-in-use case, an unexpected error
211+ # on every port (e.g. EACCES, EADDRNOTAVAIL) would leave
212+ # last_error == None and turn `raise last_error` into
213+ # `raise None`, masking the real failure with a confusing
214+ # TypeError.
215+ last_error = e
208216 # errno.EADDRINUSE resolves to the platform's value (48 on
209217 # macOS, 98 on Linux), so a port-in-use bind failure is
210- # recognized cross-platform. Otherwise last_error stays None on
211- # Linux and `raise last_error` below becomes `raise None` .
218+ # recognized cross-platform and downgraded to an info log while
219+ # we try the next port .
212220 if e .errno == errno .EADDRINUSE :
213221 logger .info (f"Port { port } is in use" )
214- last_error = e
222+ else :
223+ logger .warning (f"Unexpected error binding port { port } : { e } " )
215224 except webbrowser .Error as e :
216225 # No browser could be launched at all (webbrowser.get() found no
217226 # runnable browser). This is a strong, reliable headless signal
You can’t perform that action at this time.
0 commit comments