﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34535	"dbshell management command can crash if DATABASES[""name""] is a PosixPath"	Jan Pieter Waagmeester	Jan Pieter Waagmeester	"With a sqlite database configured in `settings.py` like this:


{{{
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.
"	Bug	closed	Core (Management commands)	4.2	Normal	fixed		Adam Johnson	Ready for checkin	1	0	0	0	0	0
