Opened 8 years ago

Closed 8 years ago

#26398 closed Cleanup/optimization (duplicate)

FieldFile open() ignores the mode, always opening the file for reading

Reported by: Alexey Kotlyarov Owned by: nobody
Component: File uploads/storage Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

FieldFile.open has a mode parameter, which is always ignored. This is a test from the PR:

    def test_filefield_write(self):
        # Files can be written to
        obj = Storage.objects.create(
            normal=SimpleUploadedFile("assignment.txt", b"content"))
        with obj.normal as normal:
            normal.open('wb')
            normal.write(b"updated")
        obj = Storage.objects.get()
        self.assertEqual(obj.normal.read(), b"updated")

It fails on at least 1.8 and master with "File not open for writing" on write().

Pull request with a fix: https://github.com/django/django/pull/6325

Change History (7)

comment:1 by Alexey Kotlyarov, 8 years ago

Component: UncategorizedFile uploads/storage

comment:2 by Tim Graham, 8 years ago

Has patch: set
Triage Stage: UnreviewedReady for checkin
Type: UncategorizedCleanup/optimization

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In a52a531:

Fixed #26398 -- Made FieldFile.open() respect its mode argument.

comment:4 by Tim Graham <timograham@…>, 8 years ago

In 7def55c3:

Reverted "Fixed #26398 -- Made FieldFile.open() respect its mode argument."

This reverts commit a52a531a8b34f049fba11c3ee7b010af7534bf90 due to
regressions described in refs #26772.

comment:5 by Tim Graham <timograham@…>, 8 years ago

In bdc29b7:

[1.10.x] Reverted "Fixed #26398 -- Made FieldFile.open() respect its mode argument."

This reverts commit a52a531a8b34f049fba11c3ee7b010af7534bf90 due to
regressions described in refs #26772.

Backport of 7def55c3f6716fcfa40a3bd5d0fbb2090588d81e from master

comment:6 by Tim Graham, 8 years ago

Has patch: unset
Resolution: fixed
Status: closednew
Triage Stage: Ready for checkinAccepted

As noted in the commits above, we had to revert this fix due to some regressions reported in #26772.

comment:7 by Tim Graham, 8 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #13809

Note: See TracTickets for help on using tickets.
Back to Top