Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#19355 closed Bug (fixed)

LiveServerThread handles caught exceptions incorrectly

Reported by: flub@… Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by julien)

In a WSGIServerException is caught and the code expects it to have an errno attribute. However not WSGIServerException is a subclass of Exception and thus not guaranteed to have the errno attribute. The following short patch avoids this problem:

diff --git a/django/test/ b/django/test/
index 3bb40a5..ef4c8118 100644
--- a/django/test/
+++ b/django/test/
@@ -1022,7 +1022,7 @@ class LiveServerThread(threading.Thread):
                         (, port), QuietWSGIRequestHandler)
                 except WSGIServerException as e:
                     if (index + 1 < len(self.possible_ports) and
-                        e.args[0].errno == errno.EADDRINUSE):
+                        getattr(e.args[0], 'errno', 0) == errno.EADDRINUSE):
                         # This port is already in use, so we go on and try with
                         # the next one in the list.

Attachments (0)

Change History (3)

comment:1 Changed 17 months ago by julien

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Thanks for the report. I've fixed the formatting – please use 'Preview' in the future.

comment:2 Changed 17 months ago by Julien Phalip <jphalip@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 612357f8ef729689cf52101add8c90d0528a7421:

Fixed #19355 -- Improved LiveServerThread's handling of exceptions. Thanks to flub for the report.

comment:3 Changed 17 months ago by Julien Phalip <jphalip@…>

In 2e5b725197db406aa8b94aa4a86e2bac3dc571b1:

[1.5.x] Fixed #19355 -- Improved LiveServerThread's handling of exceptions. Thanks to flub for the report.
Backport of 612357f8ef

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.