Thanks for the response Andy. The code does work fine in the interpreter. It's when the code is called from a web page where it throws an error. I know it has something to do with unicode but I can't understand why os.stat is behaving differently. To test from a view:
----------------------------------------------------------------------------------------------------- Relevant URL in urls.py ----------------------------------------------------------------------------------------------------- [EMAIL PROTECTED]:/home/published/www/django/catalog/music# grep demo urls.py (r'^demo/$', 'music.views.demo'), ----------------------------------------------------------------------------------------------------- Call to checkpath from views.py ----------------------------------------------------------------------------------------------------- [EMAIL PROTECTED]:/home/published/www/django/catalog/music# head -16 views.py import django.shortcuts as shortcuts from django.template import RequestContext from django.http import HttpResponseRedirect from django.contrib.contenttypes.models import ContentType import models import music.demo def demo(request): music.demo.checkpath() return HttpResponseRedirect('http://google.com') ----------------------------------------------------------------------------------------------------- And the error (via http://domain.tld/demo) ----------------------------------------------------------------------------------------------------- Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode character u'\xf3' in position 35: ordinal not in range(128) Exception Location: /usr/lib/python2.5/posixpath.py in exists, line 171 Python Executable: /usr/bin/python Python Version: 2.5.2 Traceback: File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/home/published/www/django/catalog/music/views.py" in demo 14. music.demo.checkpath() File "/usr/lib/python2.5/posixpath.py" in exists 171. st = os.stat(path) Exception Type: UnicodeEncodeError at /demo/ Exception Value: 'ascii' codec can't encode character u'\xf3' in position 35: ordinal not in range(128) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---