Opened 14 years ago
Closed 14 years ago
#14902 closed (invalid)
Won't delete files with accents (or other unicode characters)
Reported by: | typeshige | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.2 |
Severity: | Keywords: | unicode | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I did some searches and didn't find it. I have a model with an ImageField. When I try to delete, it fails whenever the filename has accents. I'm using Linux.
/home/django/.virtualenvs/astrobiology/lib/python2.6/site-packages/django/core/files/storage.pyc in delete(self, name)
190 name = self.path(name)
191 # If the file exists, delete it from the filesystem.
--> 192 if os.path.exists(name):
193 os.remove(name)
194
/home/django/.virtualenvs/astrobiology/lib/python2.6/genericpath.pyc in exists(path)
16 """Test whether a path exists. Returns False for broken symbolic links"""
17 try:
---> 18 st = os.stat(path)
19 except os.error:
20 return False
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 103: ordinal not in range(128)
Change History (2)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Getting a UnicodeEncodeError
from file system function like os.stat means your server's environment is not set up correctly to allow passing unicode strings containing non-ASCII characters to the base file system functions. See: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror (though that is in the mod_python doc it is not mod_python specific).
I've been doing more testing and it seems to fail on 'normal' filenames sometimes too.
It seem to fail on the same filename whenever doing something like:
or
It fails on the same file each time, so if I isolate the offending object like this:
there is no problem. How can this be? Are the loops too fast?
My model Image looks like this: