#32557: Fail tests when unraisable exceptions occur
-----------------------------------+------------------------------------
     Reporter:  Adam Johnson       |                    Owner:  nobody
         Type:  New feature        |                   Status:  new
    Component:  Testing framework  |                  Version:  dev
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by Adam Johnson):

 Exceptions in `__del__` are only one kind of unraisable exception. The
 other kind I know of that motivated me to look into them are from async
 tasks that were not joined by the task that spawned them.

 Python already prints tracebacks for unraisable exceptions, the main point
 of this ticket is to ensure that such tracebacks in tests do not get
 missed because the tests exit with a 0 status code. The default behaviour
 looks like this:

 {{{
 $ cat test.py
 class Naughty:
     def __del__(self):
         1 / 0


 Naughty()

 $ python test.py
 Exception ignored in: <function Naughty.__del__ at 0x1015da8b0>
 Traceback (most recent call last):
   File "/Users/chainz/tmp/test/test.py", line 3, in __del__
     1 / 0
 ZeroDivisionError: division by zero

 $ echo $?
 0
 }}}

 The PR disabling gc affects only objects in cycles, which are a minority.
 Moreover all garbage is still collected at interpreter shutdown, so any
 unraisable exceptions would have their traceback printed at that point,
 although they indeed not be picked up by a sys.unraisablehook installed
 only for the duration of the test run. That said, the gc PR affects only
 the Django test suite which has no unraisable exceptions at the moment,
 and it's likely if any were added someone would spot them.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32557#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.8ca2834a11e46bcf943104e90737a249%40djangoproject.com.

Reply via email to