﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9579	problem with safe_join function from django.utils._os	Gonzalo Delgado	Karen Tracey	"The directory I use for most of my programming work is '/home/gonzalo/Código' (código is spanish for ""code"").
Since my django projects live inside that directory, TEMPLATE_DIRS always contains it.
I got this problem when loading templates from an app within that directory (Django hinted: ""The string that could not be encoded/decoded was: alo/C��digo"")
This problem best explained with this example:


{{{
$ cd Código/
$ python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49) 
[GCC 4.3.2] on linux2
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
>>> from django.utils import _os
>>> _os.safe_join('spam', 'eggs')
Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""/usr/lib/python2.5/site-packages/django/utils/_os.py"", line 16, in safe_join
    final_path = normcase(abspath(join(base, *paths)))
  File ""/usr/lib/python2.5/posixpath.py"", line 403, in abspath
    path = join(os.getcwd(), path)
  File ""/usr/lib/python2.5/posixpath.py"", line 65, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128)
}}}

'''safe_join''' uses '''force_unicode''' to convert 'spam' and 'eggs' to unicode objects, but then uses '''os.path.abspath''' which obtains the working directory ('/home/gonzalo/Código') and tries to join it with u'spam' and u'eggs' and fails.
"		closed	Uncategorized	dev		fixed	bug utils _os safe_join		Accepted	1	0	1	1	0	0
