#3582 closed (fixed)
Newforms tests fail under Python2.3 -- unicode related
Reported by: | Jacob | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | newforms unicode python2.3 tests unicode-branch | |
Cc: | adurdin@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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...
Change History (7)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 18 years ago
Cc: | added |
---|
comment:3 by , 18 years ago
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.
comment:4 by , 18 years ago
comment:5 by , 18 years ago
Keywords: | unicode-branch added |
---|
This is fixed on the unicode branch in [5223]. I'll close the ticket when the branch is merged back into trunk.
comment:6 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Might this be failing due to the use of str() instead of unicode(), as highlighted in #3597?