Author: jacob
Date: 2008-08-27 15:53:02 -0500 (Wed, 27 Aug 2008)
New Revision: 8636
Modified:
django/trunk/django/core/files/uploadedfile.py
django/trunk/tests/regressiontests/file_storage/tests.py
Log:
FIxed #8156: `UploadedFile.__repr__` now returns a string, a good `__repr__`
should.
Modified: django/trunk/django/core/files/uploadedfile.py
===================================================================
--- django/trunk/django/core/files/uploadedfile.py 2008-08-27 20:29:58 UTC
(rev 8635)
+++ django/trunk/django/core/files/uploadedfile.py 2008-08-27 20:53:02 UTC
(rev 8636)
@@ -11,6 +11,7 @@
from django.conf import settings
from django.core.files.base import File
from django.core.files import temp as tempfile
+from django.utils.encoding import smart_str
__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
'SimpleUploadedFile')
@@ -32,7 +33,7 @@
self.charset = charset
def __repr__(self):
- return "<%s: %s (%s)>" % (self.__class__.__name__, self.name,
self.content_type)
+ return "<%s: %s (%s)>" % (self.__class__.__name__,
smart_str(self.name), self.content_type)
def _get_name(self):
return self._name
Modified: django/trunk/tests/regressiontests/file_storage/tests.py
===================================================================
--- django/trunk/tests/regressiontests/file_storage/tests.py 2008-08-27
20:29:58 UTC (rev 8635)
+++ django/trunk/tests/regressiontests/file_storage/tests.py 2008-08-27
20:53:02 UTC (rev 8636)
@@ -1,3 +1,4 @@
+# coding: utf-8
"""
Tests for the file storage mechanism
@@ -72,6 +73,14 @@
# Cleanup the temp dir
>>> os.rmdir(temp_dir)
+
+# Regression test for #8156: files with unicode names I can't quite figure out
the
+# encoding situation between doctest and this file, but the actual repr doesn't
+# matter; it just shouldn't return a unicode object.
+>>> from django.core.files.uploadedfile import UploadedFile
+>>> uf = UploadedFile(name=u'¿Cómo?',content_type='text')
+>>> uf.__repr__()
+'<UploadedFile: ... (text)>'
"""
# Tests for a race condition on file saving (#4948).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---