Skip to content

Commit

Permalink
Fix on Python 2 by conditionally choosing between providing __bytes__…
Browse files Browse the repository at this point in the history
… and __str__
  • Loading branch information
MatthewWilkes committed May 9, 2018
1 parent a641325 commit 60fcd52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plone/namedfile/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __len__(self):
data = bytes(self)
return len(data)

def __bytes__(self):
def _get_contents(self):
next = self.next
if next is None:
return self._data
Expand All @@ -58,6 +58,11 @@ def __bytes__(self):

return b''.join(result)

if six.PY2:
__str__ = _get_contents
else:
__bytes__ = _get_contents


FILECHUNK_CLASSES = [FileChunk]
try:
Expand Down

0 comments on commit 60fcd52

Please sign in to comment.