From 51df0dff3c4f28016185a9e876ee5b3420712f99 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 4 Jan 2025 03:30:40 +0000 Subject: [PATCH] Fixed #36057 -- Enabled test runner to debug chained exceptions with `--pdb` on Python 3.13+. --- django/test/runner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/django/test/runner.py b/django/test/runner.py index a52c52fe21..b83cd37343 100644 --- a/django/test/runner.py +++ b/django/test/runner.py @@ -30,7 +30,7 @@ from django.test.utils import setup_test_environment from django.test.utils import teardown_databases as _teardown_databases from django.test.utils import teardown_test_environment from django.utils.datastructures import OrderedSet -from django.utils.version import PY312 +from django.utils.version import PY312, PY313 try: import ipdb as pdb @@ -126,7 +126,10 @@ class PDBDebugResult(unittest.TextTestResult): self.buffer = False exc_type, exc_value, traceback = error print("\nOpening PDB: %r" % exc_value) - pdb.post_mortem(traceback) + if PY313: + pdb.post_mortem(exc_value) + else: + pdb.post_mortem(traceback) class DummyList: