#10632 closed (worksforme)
rare bug with log deletion in admin
Reported by: | sdfsdhgjkbmnmxc | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | logging | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Admin interface. When we delete object with long unicode representation it may be wrong truncated: "object_repr[:200]" may intersect utf-8 pair bytes.
Next we have "'utf8' codec can't decode byte 0xd0 in position 199: unexpected end of data." error.
This is very rare bug, but today i have it.
Fix is one-line:
ModelAdmin.log_addition(), and ModelAdmin.log_change() has force_unicode inside:
object_repr = force_unicode(object),
but ModelAdmin.log_deletion() hasn't force_unicode inside:
object_repr = object_repr,
Change History (5)
comment:1 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
comment:3 by , 16 years ago
Ramiro: the reason for the force_unicode()
calls that you point to is just historical due to the unicode and newforms-admin branches being done in parallel. We can remove the latter one at some point.
That being said, I agree with you about the log_deletion()
case. I can't see how this can be happening and attempting to repeat it with something with a UTF-8 representation around 1000 bytes didn't repeat it (I was using chinese characters and various offsets, so it should have been triggered).
For the original reporter: what version of Python and Django were you using when you triggered this problem?
comment:4 by , 16 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Marking worksforme per Malcolm; please reopen with more info if someone else can reproduce.
This could be an user error because
object_repr
is already the result of callingforce_unicode()
on the model instance being deleted beforelog_deletion() is called
. Maybe the__unicode__()
model method provided by the user isn't returning an Unicode string?.OTOH, we seem to be already being permissive with this error because we are calling
force_unicode()
twice when showing the message to the user: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py?rev=10314#L1005