On Mon, Feb 23, 2009 at 7:10 PM, arbi <arbin...@gmail.com> wrote:

>
> Here is the Traceback, need something else?
>
> Traceback:
> File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
> in get_response
>  86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Users/brouard/antrive_docs/antrive/../antrive/routes/views.py"
> in route_result
>  122.  departure_char_list = list(gmaps_geocoder.geocode(departure,
> exactly_one=False))
> File "/Library/Python/2.5/site-packages/geopy-0.93dev_r75-py2.5.egg/
> geopy/geocoders_old.py" in geocode
>  327.         url = self.url % urlencode(params)
> File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/urllib.py" in urlencode
>  1250.             v = quote_plus(str(v))
>
> Exception Type: UnicodeEncodeError at /routes/index/result/
> Exception Value: 'ascii' codec can't encode character u'\xe9' in
> position 11: ordinal not in range(128)
>

So how you read that is, starting from the bottom:

urllib.py line 1250, in the urlencode function (based on the full path part
of Python itself) generated the exception with this line of code:

v = quote_plus(str(v))

A little experience with Python and Unicode and the text of the error itself
makes it pretty clear the problem is the str(v): apparently v here is a
Unicode object with non-ASCII characters.  Any attempt to do str(v) on such
a thing is going to generate this error.  So apparently urlencode doesn't
support being passed such Unicode objects.  I believe this a well-known
limitation of Python's urlencode function.

What code passed this problematic value into urlencode?  Look one level up
in the traceback.  Caller is a geocode function in geocoders_old.py, line
327 (based on the path apparently part of geopy 0.93).

What called it and what parameters did it pass?  Looking up farther, your
views.py code in route_result.  It seems the only thing you are passing in
that could ultimately be passed on as the value causing the error is
'departure'.  A fix, as Malcolm's reply notes, might be to explicitly encode
departure before passing it into geocoder.  Alternatively you could search
for weather anyone has reported this a a problem in geopy, in which case you
might find this:

http://groups.google.com/group/geopy/browse_thread/thread/7a8a95900a13d5dc#

which seems to indicate at least one other person has run into this error
and thought it should be fixed in geopy itself.  There's no response to that
post that I can see, though, so apparently it's still up to your code to fix
it, by explicitly encoding Unicode values into bytestrings before sending
them into geocode.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to