Django

Code

Ticket #8910 (closed: fixed)

Opened 4 months ago

Last modified 2 months ago

Unicodedecodeerror with inline models when using speical characers and python 2.3.4

Reported by: joshg Assigned to: nobody
Milestone: Component: Uncategorized
Version: 1.0-beta-1 Keywords: python2.3 unicode
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I am using SVN checkout 8972 of Django with Python 2.3.4 and mod_python . In one of my models http://dpaste.com/hold/76255/ 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) http://dpaste.com/hold/76259/.

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.

Thanks,

Josh

Attachments

test_admin_views.diff (0.7 kB) - added by nfg on 11/06/08 11:52:46.
admin_options.diff (1.6 kB) - added by nfg on 11/06/08 12:41:21.

Change History

11/06/08 11:52:46 changed by nfg

  • attachment test_admin_views.diff added.

11/06/08 12:32:41 changed by nfg

  • needs_better_patch changed.
  • has_patch set to 1.
  • version changed from 1.0 to 1.0-beta-1.
  • needs_tests changed.
  • needs_docs changed.

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).

11/06/08 12:41:14 changed by brosner

  • stage changed from Unreviewed to Accepted.

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

11/06/08 12:41:21 changed by nfg

  • attachment admin_options.diff added.

11/06/08 12:46:42 changed by nfg

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 :).

11/10/08 11:26:14 changed by kmtracey

  • status changed from new to closed.
  • resolution set to fixed.

(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.


Add/Change #8910 (Unicodedecodeerror with inline models when using speical characers and python 2.3.4)




Change Properties
Action