From 565341b5faeacc912900bb244afc956cbf4a0a2a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 22 Apr 2015 00:26:01 +0200 Subject: Fix fileapp on Python 3 * Don't compare None with int * Add __next__() method (alias to next()). * HTTP body must be bytes * Don't use string.letters but an hardcoded string to not depend on the locale. --- paste/fileapp.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'paste') diff --git a/paste/fileapp.py b/paste/fileapp.py index 3825386..e18281a 100644 --- a/paste/fileapp.py +++ b/paste/fileapp.py @@ -122,7 +122,7 @@ class DataApp(object): for head in list_headers(entity=True): head.delete(headers) start_response('304 Not Modified', headers) - return [''] + return [b''] except HTTPBadRequest as exce: return exce.wsgi_application(environ, start_response) @@ -133,12 +133,13 @@ class DataApp(object): if not client_etags: try: client_clock = IF_MODIFIED_SINCE.parse(environ) - if client_clock >= int(self.last_modified): + if (client_clock is not None + and client_clock >= int(self.last_modified)): # horribly inefficient, n^2 performance, yuck! for head in list_headers(entity=True): head.delete(headers) start_response('304 Not Modified', headers) - return [''] # empty body + return [b''] # empty body except HTTPBadRequest as exce: return exce.wsgi_application(environ, start_response) @@ -224,11 +225,11 @@ class FileApp(DataApp): if isinstance(retval, list): # cached content, exception, or not-modified if is_head: - return [''] + return [b''] return retval (lower, content_length) = retval if is_head: - return [''] + return [b''] file.seek(lower) file_wrapper = environ.get('wsgi.file_wrapper', None) if file_wrapper: @@ -256,6 +257,7 @@ class _FileIter(object): if not data: raise StopIteration return data + __next__ = next def close(self): self.file.close() -- cgit v1.2.1