the workaround is to change the locale to en_US:
{{{
$ export LANG=en_US.UTF-8
}}}
and it works
--
Ticket URL: <https://code.djangoproject.com/ticket/20572>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* component: Uncategorized => Core (Management commands)
* needs_tests: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:1>
Comment (by claudep):
Note that I can currently reproduce the error with
`fixtures_regress.tests.TestFixtures.test_loaddata_raises_error_when_fixture_has_invalid_foreign_key`
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:2>
Comment (by claudep):
Also note that this is a Python2-only issue.
Some possible solutions:
* using `%r` instead `%s`. Drawback: the resulting message is not quite
the same:
{{{
e.args = ("Problem installing fixtures: %s" % e,)
(u"Problem installing fixtures: The row in table 'fixtures_regress_book'
with primary key '1' has an invalid
foreign key: fixtures_regress_book.author_id contains a value '3' that
does not have a corresponding value in
fixtures_regress_person.id.",)
e.args = ("Problem installing fixtures: %r" % e,)
(u'Problem installing fixtures: IntegrityError(u"The row in table
\'fixtures_regress_book\' with primary key
\'1\' has an invalid foreign key: fixtures_regress_book.author_id contains
a value \'3\' that does not have a
corresponding value in fixtures_regress_person.id.",)',)
}}}
And we should still track this pattern all over Django code.
* using `force_text` in `DatabaseErrorWrapper` to convert message to
unicode.[[BR]]
Drawback: non-ascii unicode args for exceptions are not well supported,
notably in unittest2 `assertRaisesRegexp` where `str(exc_value)` will
raise a `UnicodeEncodeError`.
* using `force_text(s, 'ascii', errors='ignore')` in
`DatabaseErrorWrapper` to strip out any non-ascii char from the exception
message.[[BR]]
Drawback: the error message will be altered.
Opinions or other solutions welcome.
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:3>
* status: new => closed
* needs_better_patch: 0 => 1
* component: Core (Management commands) => contrib.admin
* needs_tests: 0 => 1
* version: 1.5 => master
* easy: 0 => 1
* type: Bug => Uncategorized
* keywords: => 1
* needs_docs: 0 => 1
* has_patch: 0 => 1
* ui_ux: 0 => 1
* resolution: => fixed
* stage: Accepted => Unreviewed
Comment:
1
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:5>
* needs_better_patch: 0 => 1
* component: Core (Management commands) => contrib.admin
* needs_tests: 0 => 1
* version: 1.5 => master
* easy: 0 => 1
* keywords: => 1
* needs_docs: 0 => 1
* has_patch: 0 => 1
* ui_ux: 0 => 1
* type: Bug => Uncategorized
* stage: Accepted => Unreviewed
Comment:
1
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:4>
* status: new => assigned
* needs_better_patch: 0 => 1
* component: Core (Management commands) => contrib.admin
* needs_tests: 0 => 1
* keywords: => 1
* version: 1.5 => master
* easy: 0 => 1
* owner: nobody => anonymous
* needs_docs: 0 => 1
* has_patch: 0 => 1
* ui_ux: 0 => 1
* type: Bug => Uncategorized
* stage: Accepted => Unreviewed
Comment:
1
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:6>
* keywords: => 1
* type: Bug => Uncategorized
* version: 1.5 => master
* component: Core (Management commands) => contrib.admin
Comment:
1
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:7>
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:4>
Comment (by EmilStenstrom):
There are lots of other cases where printing error messages in ascii could
lead to problems. I'm not sure if there are more bugs covering this, so
I'll add a small description here:
I have a model who's __unicode__() method returns:
{{{
<MailComment: \n\nK\xc3\xb6r jobbet nu och det verkar bli fel...>
}}}
When loading my fixture I get: ValueError('Cannot assign [unicode
representation of MailComment here]') which get propagated to fixture
loading and makes that crash with:
{{{
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 32:
ordinal not in range(128)
}}}
Using %r instead of %s seems reasonable, as it doesn't remove any of the
offending characters (they are often the reason for the exception in the
first place), and it will likely work well with all sorts of environments.
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:5>
Comment (by claudep):
#22882 reports a similar issue with the `flush` command.
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:6>
Comment (by timgraham):
Can we add `from __future__ import unicode_literals` to `dumpdata.py`?
This strategy seems to fixed the issue for `flush`.
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:7>
Comment (by claudep):
#25719 was a duplicate.
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:8>
* status: new => closed
* resolution: => wontfix
Comment:
Django master is now Python 3 only, therefore I'll close this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/20572#comment:9>