#34535: dbshell management command can crash if DATABASES["name"] is a PosixPath
-------------------------------------+-------------------------------------
               Reporter:  Jan        |          Owner:  nobody
  Pieter Waagmeester                 |
                   Type:  Bug        |         Status:  new
              Component:  Core       |        Version:  4.2
  (Management commands)              |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34535>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070187e1d0e241-cf988f84-e4e3-4fae-af21-23ada0074fea-000000%40eu-central-1.amazonses.com.

Reply via email to