Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1763 (closed defect: invalid)

Opened 11 years ago

Last modified 11 years ago

Redirecting to UTF-8-Urls doesnt work

Reported by: theomega Owned by: chrisz
Priority: normal Milestone: 1.1
Component: TurboGears Version: 1.0.4.3
Severity: normal Keywords: unicode, redirect, ascii
Cc: dominik@…, kov@…

Description

Trying to redirect to a url containing non-ascii-chars gives the following error:


Page handler: 'ordinal not in range(128)' Traceback (most recent call last):

File "/var/lib/python-support/python2.4/cherrypy/_cphttptools.py", line 120, in _run

cherrypy.response.finalize()

File "/var/lib/python-support/python2.4/cherrypy/_cphttptools.py", line 408, in finalize

self.header_list = self.headers.sorted_list()

File "/var/lib/python-support/python2.4/cherrypy/lib/httptools.py", line 468, in sorted_list

header_list.append((order, (key, unicode(value))))

UnicodeEncodeError?: 'ascii' codec can't encode character u'\xfc' in position 42: ordinal not in range(128)


This can be reproduced by adding a redirect("München") to the controller. It doesnt matter if you use a hardcoded Url or a String (from db) which contains non-asci-chars.

Attachments

unicodeLogging.patch Download (1015 bytes) - added by matiu 11 years ago.

Change History

comment:1 Changed 11 years ago by theomega

Sorry for the difference in line 468 of lib/httptools.py, i tried changing "str(" to "unicode(" but this doesnt fix the error!

comment:2 Changed 11 years ago by Chris Arndt

It seems that you are using a CherryPy? installation from a distribution (probably Ubuntu or Debian) package. Can you confirm that this error also occurs when you install CherryPy? >= 2.3.0 from the Cheeseshop?

comment:3 Changed 11 years ago by theomega

Yes, this is a turbogears installation from debian unstable, which pulled in all depencies. My CherryPy? Version is therefor "2.2.1-4". Can you guide me how to install the newer version without damaging the debian installation?

comment:4 Changed 11 years ago by theomega

  • Cc dominik@… added

comment:6 Changed 11 years ago by theomega

Okay, your right, this is fixed in 2.3.0. Perhaps you should notify the debian package-maintainer.

comment:7 Changed 11 years ago by Chris Arndt

  • Cc kov@… added

comment:8 Changed 11 years ago by matiu

There is a patch for this in #1823 (which is a duplicate of this bug). The patch fixes this in turbogears 1.1

comment:9 Changed 11 years ago by matiu

  • Owner changed from anonymous to chrisz

I assigned this to chrisz, because in svn annotate he was last to touch the line that is causing the bug (although, I think it never worked).

Changed 11 years ago by matiu

comment:10 Changed 11 years ago by matiu

I just uploaded the same patch from #1823. Don't be fooled by it's crossed outness. It's only closed to merge it with this bug, the patch still needs applying in 1.1 branch please :)

Of course this will kind of force everyone that uses turbogears to use UTF-8 encoding (or compatible ASCII). But better to have one non-ascii encoding working than none. Also I think UTF-8 pretty much a defacto standard eh..

comment:11 Changed 11 years ago by matiu

Sorry for all the spam. One more thing:

The traceback in this bug is for a bug in cherrypy, which has of course been fixed.

The patch fixes a bug in turbogears with the same error message but a different traceback.

comment:12 Changed 11 years ago by faide

  • Milestone changed from 1.5 to 1.1

comment:13 Changed 11 years ago by Chris Arndt

  • Status changed from new to closed
  • Resolution set to invalid

So the original bug was already fixed in CherryPy 2.3.0 so this bug should be closed as invalid.

As for the second problem, referred to from comment no. 8 onwards, this is a separate issue and should be reported in it's own ticket. Also, I can not reproduce the error the attached patch is trying to fix with TG 1.0.6 (the code in controllers.py is still the same as it was at the time the patch was created).

I'm closing this ticket as invalid now. If you still get the problem, please open a new ticket with example code that demonstrates the issue.

Note: See TracTickets for help on using tickets.