diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-04-21 15:39:39 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-04-21 15:39:39 +0200 |
commit | 4c4ee4517be0365ddc03fba9cbbce7486be4733b (patch) | |
tree | 2239aade108979a52fd4e1008c3c729cdfdb1b7b /paste | |
parent | 0a75a95f8905f67460a00112193ca40214cdd7c1 (diff) | |
download | paste-4c4ee4517be0365ddc03fba9cbbce7486be4733b.tar.gz |
Fix paste.request on Python 3
WSGI input must be a binary file (BytesIO), not a text file (StringIO).
Add also the missing __len__() method to EnvironHeaders, it's now required on
Python 3 by the MutableMapping ABC.
Diffstat (limited to 'paste')
-rw-r--r-- | paste/request.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/paste/request.py b/paste/request.py index 743ab97..2e7280b 100644 --- a/paste/request.py +++ b/paste/request.py @@ -18,7 +18,6 @@ environment to solve common requirements. """ import cgi -from six.moves import StringIO from six.moves.urllib import parse as urlparse from six.moves.urllib.parse import quote try: @@ -32,6 +31,7 @@ try: from UserDict import DictMixin except ImportError: from collections import MutableMapping as DictMixin +import six from paste.util.multidict import MultiDict @@ -175,7 +175,7 @@ def parse_formvars(environ, include_get_vars=True): old_query_string = environ.get('QUERY_STRING','') environ['QUERY_STRING'] = '' if fake_out_cgi: - input = StringIO('') + input = six.BytesIO(b'') old_content_type = environ.get('CONTENT_TYPE') old_content_length = environ.get('CONTENT_LENGTH') environ['CONTENT_LENGTH'] = '0' @@ -376,6 +376,9 @@ class EnvironHeaders(DictMixin): else: return None + def __len__(self): + return len(self.environ) + def __getitem__(self, item): return self.environ[self._trans_name(item)] |