{{{
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
}}}
exiting `./manage.py dbshell` using `Control - d` sometimes results in
this exception:
{{{
Traceback (most recent call last):
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/core/management/commands/dbshell.py", line 30, in handle
connection.client.runshell(options["parameters"])
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/db/backends/base/client.py", line 28, in runshell
subprocess.run(args, env=env, check=True)
File "/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['sqlite3',
PosixPath('/home/ubuntu/planning-poker/db.sqlite3')]' returned non-zero
exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ubuntu/planning-poker/./manage.py", line 30, in <module>
main()
File "/home/ubuntu/planning-poker/./manage.py", line 26, in main
execute_from_command_line(sys.argv)
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/core/management/__init__.py", line 442, in
execute_from_command_line
utility.execute()
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/virtualenv/lib/python3.11/site-
packages/django/core/management/commands/dbshell.py", line 44, in handle
" ".join(e.cmd),
^^^^^^^^^^^^^^^
TypeError: sequence item 1: expected str instance, PosixPath found
}}}
coercing each item in `e.cmd` to string should fix this.
--
Ticket URL: <https://code.djangoproject.com/ticket/34535>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Jan Pieter Waagmeester
* status: new => assigned
* has_patch: 0 => 1
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
Comment:
felix will update the name to be specific to the error
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:1>
Comment (by David Sanders):
PR: https://github.com/django/django/pull/16824
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:2>
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:3>
* cc: Adam Johnson (added)
Comment:
Regression in 5b884d45ac5b76234eca614d90c83b347294c332.
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f5b39b77e38b7585861df9314aba4ce93b018c4c" f5b39b7]:
{{{
#!CommitTicketReference repository=""
revision="f5b39b77e38b7585861df9314aba4ce93b018c4c"
Fixed #34535 -- Fixed SQLite dbshell crash on pathlib.Path when handling
CommandError.
Regression in 5b884d45ac5b76234eca614d90c83b347294c332.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:6>
Comment (by Adam Johnson):
I also just hit this. Thanks for the fix.
For completeness, the "sometimes" depends on the exit code of SQLite,
which is non-zero if the last run query was an error, for example:
{{{
$ ./manage.py dbshell
SQLite version 3.39.5 2022-10-14 20:58:05
Enter ".help" for usage hints.
sqlite> select;
Parse error: near ";": syntax error
select;
^--- error here
sqlite> ^D
Traceback (most recent call last):
...
TypeError: sequence item 1: expected str instance, PosixPath found
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34535#comment:7>