diff options
author | Thomas Cross <tcross@csgactuarial.com> | 2020-01-28 09:53:26 -0600 |
---|---|---|
committer | Chris Dent <cdent@anticdent.org> | 2020-01-28 15:53:26 +0000 |
commit | b9d39dc9ff6c6d70b00bc2b764fb4fc6b38eb239 (patch) | |
tree | 218eaa9aec879b5a64063f016134450f82b8aa1c | |
parent | e9827316dfb827a8005dbfc9b370edd7d330773e (diff) | |
download | paste-git-b9d39dc9ff6c6d70b00bc2b764fb4fc6b38eb239.tar.gz |
add six to check for python 2 or 3 specific implementation (#48)
* StringIO imports differently in python 3 - use six for compatibility
* Paste requires bytes like objects. in python 2 cStringIO works fine, but in python three it needs to use io.BytesIO
* simplify imports and logic by using six.BytesIO exclusively for parsing body content
-rw-r--r-- | paste/cascade.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/paste/cascade.py b/paste/cascade.py index e1e8235..3f6b661 100644 --- a/paste/cascade.py +++ b/paste/cascade.py @@ -8,7 +8,7 @@ return ``404 Not Found``. from paste import httpexceptions from paste.util import converters import tempfile -from six.moves import cStringIO as StringIO +from six import BytesIO __all__ = ['Cascade'] @@ -104,7 +104,9 @@ class Cascade(object): copy_len -= len(chunk) f.seek(0) else: - f = StringIO(environ['wsgi.input'].read(length)) + f = BytesIO(environ['wsgi.input'].read(length)) + + environ['wsgi.input'] = f else: copy_wsgi_input = False |