Ticket #14681: django_mode_patch.diff

File django_mode_patch.diff, 1.1 KB (added by Brad Greenlee, 14 years ago)
  • django/core/files/base.py

     
    1515        if name is None:
    1616            name = getattr(file, 'name', None)
    1717        self.name = name
    18         self.mode = getattr(file, 'mode', None)
     18        if hasattr(file, 'mode'):
     19            self.mode = getattr(file, 'mode')
    1920
    2021    def __str__(self):
    2122        return smart_str(self.name or '')
  • tests/modeltests/files/tests.py

     
    9292        obj4.random.save("random_file", ContentFile("random content"))
    9393        self.assertTrue(obj4.random.name.endswith("/random_file"))
    9494
     95        # should not set mode to None if it is not present
     96        file = SimpleUploadedFile("mode_test.txt", "content")
     97        self.assertFalse(hasattr(file, 'mode'))
     98
    9599        # Clean up the temporary files and dir.
    96100        obj1.normal.delete()
    97101        obj2.normal.delete()
Back to Top