[Django] #37109: Suppress KeyboardInterrupt traceback in dbshell

1 view
Skip to first unread message

Django

unread,
May 19, 2026, 12:49:49 PM (2 days ago) May 19
to django-...@googlegroups.com
#37109: Suppress KeyboardInterrupt traceback in dbshell
-------------------------------------+-------------------------------------
Reporter: | Owner: Vikashgraja
Vikashgraja |
Type: | Status: assigned
Cleanup/optimization |
Component: Core | Version: 6.0
(Management commands) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
When running `python manage.py dbshell` and exiting with Ctrl+C,
Django prints a full traceback originating from `subprocess.run()`.

This is reproducible with the SQLite backend on Python 3.13.

**Example:**
{{{

$ python manage.py dbshell

SQLite version 3.51.0
sqlite> [pressed Ctrl + C]

Traceback (most recent call last):
...
File ".../django/db/backends/base/client.py", line 31, in runshell
subprocess.run(args, env=env, check=True)
...
KeyboardInterrupt

}}}

**Expected behavior:**

`dbshell` should terminate cleanly without displaying a traceback
when interrupted with Ctrl+C, since this is normal interactive shell
behavior.

The issue appears to come from `subprocess.run()` propagating
KeyboardInterrupt during interactive shell execution.

A possible fix is to suppress KeyboardInterrupt around the
`subprocess.run()` call in:

django/db/backends/base/client.py
--
Ticket URL: <https://code.djangoproject.com/ticket/37109>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 20, 2026, 10:26:39 AM (24 hours ago) May 20
to django-...@googlegroups.com
#37109: Suppress KeyboardInterrupt traceback in dbshell
-------------------------------------+-------------------------------------
Reporter: Vikash G | Owner: Vikash G
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Management | Version: 6.0
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

Comment:

Thank you, similar to #36016.
I think as part of this ticket, the KeyboardInterrupt traceback should be
reviewed of all management commands
--
Ticket URL: <https://code.djangoproject.com/ticket/37109#comment:1>
Reply all
Reply to author
Forward
0 new messages