#36057: Make `test --pdb` pass exception to `pdb.post_mortem()` on Python 3.13
-------------------------------------+-------------------------------------
     Reporter:  Adam Johnson         |                     Type:  New
                                     |  feature
       Status:  new                  |                Component:  Testing
                                     |  framework
      Version:  dev                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 Python 3.13 added support for navigating between chained exceptions in pdb
 with [https://docs.python.org/3.14/library/pdb.html#pdbcommand-exceptions
 the new 'exceptions' command].

 Currently, using `test --pdb` does not allow this navigation, failing with
 this message:

 {{{
 (Pdb) exceptions
 Did not find chained exceptions. To move between exceptions,
 pdb/post_mortem must be given an exception object rather than a traceback.
 }}}

 `PDBDebugResult` currently passes `pdb.post_mortem()`  the traceback
 object. But it turns out that the pdb changes in 3.13 also allow passing
 an exception here, which is currently undocumented but I
 [https://github.com/python/cpython/pull/128410 submitted a PR].

 If we switch to passing the exception, it enables switching between
 chained exceptions:

 {{{
 > /.../django/core/management/commands/dumpdata.py(285)handle()
 -> raise CommandError("Unable to serialize database: %s" % e)
 (Pdb) exceptions
     0 TypeError("string argument expected, got 'bytes'")
 >   1 CommandError("Unable to serialize database: string argument
 expected, got 'by...
 (Pdb) exceptions 0
 > /.../django/core/management/base.py(181)write()
 -> self._out.write(style_func(msg))
 (Pdb)
 }}}

 (I actually made this change to debug a chained exception failure whilst
 working on #36056.)
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36057>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019426dd5a9b-09fb8e1b-10a6-44cd-a53c-cc849edf625c-000000%40eu-central-1.amazonses.com.

Reply via email to