Opened 9 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 , 9 years ago
Component: | Uncategorized → File uploads/storage |
---|
comment:2 by , 9 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 8 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Status: | closed → new |
Triage Stage: | Ready for checkin → Accepted |
As noted in the commits above, we had to revert this fix due to some regressions reported in #26772.
Note:
See TracTickets
for help on using tickets.
In a52a531: