Skip to content

Commit

Permalink
Fix ValueError: seek of closed file
Browse files Browse the repository at this point in the history
  • Loading branch information
millerdev committed Jul 2, 2020
1 parent 0372f63 commit a69724e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,10 @@ def __init__(self, fileobj):
def __getattr__(self, name):
return getattr(self.fileobj, name)

def open(self, *args, **kw):
# compatible with django.core.files.base.File.open()
obj = self.fileobj.open(*args, **kw)
return self if obj is self.fileobj else obj

def close(self):
pass
1 change: 1 addition & 0 deletions corehq/form_processor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def open(self):
return BytesIO(self.content)
fileobj = self.raw_content.open()

# TODO remove when Django 1 is no longer supported
if fileobj is None:
assert not isinstance(self.raw_content, BlobMeta), repr(self)
# work around Django 1.11 bug, fixed in 2.0
Expand Down

0 comments on commit a69724e

Please sign in to comment.