Ticket #16946: 16946.diff

File 16946.diff, 697 bytes (added by charettes, 4 years ago)

Make sure django File wrapper size getter raises the correct exception when called on a an instance with no name

  • django/core/files/base.py

     
    3636        if not hasattr(self, '_size'):
    3737            if hasattr(self.file, 'size'):
    3838                self._size = self.file.size
    39             elif os.path.exists(self.file.name):
    40                 self._size = os.path.getsize(self.file.name)
     39            elif self.name and os.path.exists(self.name):
     40                self._size = os.path.getsize(self.name)
    4141            else:
    4242                raise AttributeError("Unable to determine the file's size.")
    4343        return self._size
Back to Top