Opened 16 years ago

Closed 16 years ago

#8910 closed (fixed)

Unicodedecodeerror with inline models when using speical characers and python 2.3.4

Reported by: joshg Owned by: nobody
Component: Uncategorized Version: 1.0-beta
Severity: Keywords: python2.3 unicode
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I am using SVN checkout 8972 of Django with Python 2.3.4 and mod_python . In one of my models I have an inline model named StandardOptionsInline.

When I add special characters like ® (Registered Trademark Symbol) to the inlined model StandardOptionsInline I get the following error:

UnicodeDecodeError - 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)

However, if I edit the model that the inline model is based off of StandardOptions directly using the Admin interface, I can add fields with special characters like ®.

I have found that if I use Python 2.5 and the Django development server this issue does not occur. My solution will be upgrading to Python 2.5.



Attachments (2)

test_admin_views.diff (690 bytes ) - added by Nils Fredrik Gjerull 16 years ago.
admin_options.diff (1.6 KB ) - added by Nils Fredrik Gjerull 16 years ago.

Download all attachments as: .zip

Change History (6)

by Nils Fredrik Gjerull, 16 years ago

Attachment: test_admin_views.diff added

comment:1 by Nils Fredrik Gjerull, 16 years ago

Has patch: set
Version: 1.01.0-beta-1

This is yet another UnicodeDecode issue caused by lack of force_unicode encapsulation.
As explained here:

There is also a Python 2.3 issue here (a bug in 2.3): u'%s' % foo should call
foo.__unicode__, if it exists. But in 2.3, it calls foo.__str__ always. So we
need to write this as u'%s' % unicode(foo).

comment:2 by Brian Rosner, 16 years ago

Triage Stage: UnreviewedAccepted

When attaching patches to tickets, please only attach one that includes both the fix, tests and documentation (if applicable).

by Nils Fredrik Gjerull, 16 years ago

Attachment: admin_options.diff added

comment:3 by Nils Fredrik Gjerull, 16 years ago

Changed the admin_options patch a to only encapsulate the model object. I is not necessary to encapsulate unicode strings.

I will remember to only add one patch for the tests and fix next time :).

comment:4 by Karen Tracey, 16 years ago

Resolution: fixed
Status: newclosed

(In [9384]) [1.0.X] Fixed #8910 -- Added force_unicode during admin log message creation to avoid triggering a Python 2.3 bug. Thanks for the report joshg and patch nfg.

[9383] from trunk.

Note: See TracTickets for help on using tickets.
Back to Top