Django

Code

Ticket #3582 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Newforms tests fail under Python2.3 -- unicode related

Reported by: jacob Assigned to: adrian
Milestone: Component: django.newforms
Version: SVN Keywords: newforms unicode python2.3 tests unicode-branch
Cc: adurdin@gmail.com Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The newforms tests fail under Python2.3:

======================================================================
ERROR: Doctest: regressiontests.forms.tests
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jacob/Projects/Django/django/test/doctest.py", line 2150, in runTest
    failures, tries = runner.run(
  File "/Users/jacob/Projects/Django/django/test/doctest.py", line 1379, in run
    return self.__run(test, compileflags, out)
  File "/Users/jacob/Projects/Django/django/test/doctest.py", line 1267, in __run
    got += _exception_traceback(exc_info)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 249: ordinal not in range(128)
----------------------------------------------------------------------

I suspect this is either related to something about Python 2.3's unicode handling (as suggested in #3396), or perhaps some difference in how doctest operates under Python2.3. I can't really figure it out, though...

Attachments

Change History

02/26/07 13:03:15 changed by jacob

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

03/06/07 08:30:23 changed by adurdin@gmail.com

  • cc set to adurdin@gmail.com.

Might this be failing due to the use of str() instead of unicode(), as highlighted in #3597?

05/12/07 12:58:55 changed by mtredinnick

I've eventualy managed to track down the cause of this problem: it's caused by this Python bug. String interpolation into unicode strings wasn't being done correctly in Python 2.3.

The fix in this particular case is that line 374 of newforms/widgets.py has to change from

return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % w for w in self])

to

return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % unicode(w) for w in self])

The bad news is that there are a lot of places we are wanting to use this type of construction, particularly in the unicode branch. Having to wrap unicode() calls around all the arguments is going to be painful and slow things down (one extra function call for each variable argument in a lot of unicode string interpolations).

Not committing the fix right now because I'm a bit tired and want to think if there's a nicer fix (in general) that I've missed.

05/14/07 02:04:31 changed by mtredinnick

(In [5223]) unicode: Made various changes to prevent actual and potential Python 2.3 compatibility problems. Refs #3582.

05/14/07 02:05:20 changed by mtredinnick

  • keywords changed from newforms unicode python2.3 tests to newforms unicode python2.3 tests unicode-branch.

This is fixed on the unicode branch in [5223]. I'll close the ticket when the branch is merged back into trunk.

07/04/07 07:11:05 changed by mtredinnick

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

(In [5609]) Merged Unicode branch into trunk (r4952:5608). This should be fully backwards compatible for all practical purposes.

Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702


Add/Change #3582 (Newforms tests fail under Python2.3 -- unicode related)




Change Properties
Action