summaryrefslogtreecommitdiff
path: root/paste
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-22 00:26:01 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-04-22 00:26:01 +0200
commit565341b5faeacc912900bb244afc956cbf4a0a2a (patch)
tree395c204608f0e80f06db33ffea35bc7f28901075 /paste
parent82f13b6240a5a0e92f68291d90bef7e75d82a3ee (diff)
downloadpaste-565341b5faeacc912900bb244afc956cbf4a0a2a.tar.gz
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.
Diffstat (limited to 'paste')
-rw-r--r--paste/fileapp.py12
1 files changed, 7 insertions, 5 deletions
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()