              elif hasattr(self.file, 'name') and os.path.exists(self.file.name):
                  self._size = os.path.getsize(self.file.name)
              else:
                  raise AttributeError("Unable to determine the file's size.")
          return self._size
  
 
</s> remove             elif os.path.exists(self.file.name):
 </s> add             elif hasattr(self.file, 'name') and os.path.exists(self.file.name): </s> remove         # Assume the pointer is at zero...
        counter = self.size
 </s> add  </s> remove         while counter > 0:
            yield self.read(chunk_size)
            counter -= chunk_size
 </s> add         while True:
            data = self.read(chunk_size)
            if not data:
                break
            yield data </s> remove     def test_content_file_custome_name(self):
 </s> add     def test_content_file_custom_name(self):
            elif hasattr(self.file, 'tell') and hasattr(self.file, 'seek'):
                pos = self.file.tell()
                self.file.seek(0, os.SEEK_END)
                self._size = self.file.tell()
                self.file.seek(pos)
              elif hasattr(self.file, 'name') and os.path.exists(self.file.name):
                  self._size = os.path.getsize(self.file.name)
            elif hasattr(self.file, 'tell') and hasattr(self.file, 'seek'):
                pos = self.file.tell()
                self.file.seek(0, os.SEEK_END)
                self._size = self.file.tell()
                self.file.seek(pos)
              else:
                  raise AttributeError("Unable to determine the file's size.")
          return self._size
  
keep add keep keep keep keep
 Fixed #15644 -- Improved Django File wrapper to support more file-like objects. Thanks nickname123 and Michael Palumbo for working on the patch.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17871 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/core/files/base.py