diff options
author | Benjamin Peterson <benjamin@python.org> | 2019-07-24 03:46:10 -0700 |
---|---|---|
committer | Chris Dent <cdent@anticdent.org> | 2019-07-24 11:46:10 +0100 |
commit | 37bb9b45cdb55b50a4c2b371c5a0a75198863287 (patch) | |
tree | 4119dd4f3cc246ba9c3ce8859f9db0e9201cf347 /paste | |
parent | 0cfebf50090b7069a4c9b3bc6baf65693d22792d (diff) | |
download | paste-git-37bb9b45cdb55b50a4c2b371c5a0a75198863287.tar.gz |
Fix WSGIResponse.__call__ on Python 3. (#27)
Replace `isinstance(self.content, file)` with a duck type for the `read()` method. Having a read method is what PEP 333 defines as the minimum requirement for a "file-like" object.
Diffstat (limited to 'paste')
-rw-r--r-- | paste/wsgiwrappers.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py index 674054f..66bd896 100644 --- a/paste/wsgiwrappers.py +++ b/paste/wsgiwrappers.py @@ -360,11 +360,11 @@ class WSGIResponse(object): for c in self.cookies.values(): response_headers.append(('Set-Cookie', c.output(header=''))) start_response(status, response_headers) - is_file = isinstance(self.content, file) + is_file = hasattr(self.content, 'read') if 'wsgi.file_wrapper' in environ and is_file: return environ['wsgi.file_wrapper'](self.content) elif is_file: - return iter(lambda: self.content.read(), '') + return iter(lambda: self.content.read(), b'') return self.get_content() def determine_charset(self): |