[Django] #33847: `dumpdata` commands fails when invoked programmatically (but runs fine from commandline)

27 views
Skip to first unread message

Django

unread,
Jul 15, 2022, 8:00:16 AM7/15/22
to django-...@googlegroups.com
#33847: `dumpdata` commands fails when invoked programmatically (but runs fine from
commandline)
-------------------------------------+-------------------------------------
Reporter: Frederic | Owner: nobody
Brodbeck |
Type: Bug | Status: new
Component: Core | Version: 3.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 |
-------------------------------------+-------------------------------------
I want to run django's ''dumpdata'' command programmatically, however

{{{
from django.core.management import call_command
call_command('dumpdata', 'asdf', indent=2, output=filePath)
}}}
fails with {{{ Unable to serialize database: 'ascii' codec can't encode
character '\xdf' in position 83: ordinal not in range(128). }}}

running {{{ python3 manage.py dumpdata --indent=2 --output=dump.json.gz
asdf }}} from the command line works fine though!

why won't it work with {{{call_command()}}}?


----

- python version: {{{3.6.9}}}
- django version: {{{3.2.13}}}
- {{{$LANG}}} is set to {{{en_US.UTF-8}}}
- {{{$LC_ALL}}} is set to {{{en_US.UTF-8}}}
- {{{$LC_CTYPE}}} is set to {{{UTF-8}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33847>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 15, 2022, 8:23:37 AM7/15/22
to django-...@googlegroups.com
#33847: `dumpdata` commands fails when invoked programmatically (but runs fine from
commandline)
-------------------------------------+-------------------------------------
Reporter: freder | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 3.2
commands) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => invalid


Comment:

This is almost certainly a locale issue — are those `$LANG` vars really
being set in a script environment? 🤔
See (e.g.) #15017, #20572, #32439 (and links therein) for some historical
issues in this area.


You'll need to debug yourself, or provide a minimal test project that
reproduces the issue.
Happy to reopen to look if you can provide such.

--
Ticket URL: <https://code.djangoproject.com/ticket/33847#comment:1>

Reply all
Reply to author
Forward
0 new messages